<div dir="ltr"><p class="MsoNormal"><font color="#242729"><span style="font-size:15.3333px">Dear All, </span></font></p><p class="MsoNormal"><font color="#242729"><span style="font-size:15.3333px"><br></span></font></p><p class="MsoNormal"><span style="font-size:11.5pt;line-height:115%;font-family:arial,sans-serif;color:rgb(36,39,41);background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial">In a program, I generate an numpy array, with shape (128,128), which is supposed to represent an image. <span></span></span></p>

<p class="MsoNormal"><span style="font-size:11.5pt;line-height:115%;font-family:arial,sans-serif;color:rgb(36,39,41);background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial">For instance, I have<span class="gmail-apple-converted-space"> </span>an array </span><code><span style="font-size:10pt;line-height:115%;font-family:consolas;color:rgb(36,39,41);border:1pt none windowtext;padding:0in;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;background-color:rgb(239,240,241)">temp_mask</span></code><span style="font-size:11.5pt;line-height:115%;font-family:arial,sans-serif;color:rgb(36,39,41);background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial">, which is of type<span class="gmail-apple-converted-space"> </span></span><code style="white-space:pre-wrap"><span style="font-size:10pt;line-height:115%;font-family:consolas;color:rgb(36,39,41);border:1pt none windowtext;padding:0in;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;background-color:rgb(239,240,241)">float32 and
shape (128,128)</span></code><span style="font-size:11.5pt;line-height:115%;font-family:arial,sans-serif;color:rgb(36,39,41);background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial">, the maximum value is<span class="gmail-apple-converted-space"> </span></span><code style="white-space:pre-wrap"><span style="font-size:10pt;line-height:115%;font-family:consolas;color:rgb(36,39,41);border:1pt none windowtext;padding:0in;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;background-color:rgb(239,240,241)">1.0</span></code><span class="gmail-apple-converted-space"><span style="font-size:11.5pt;line-height:115%;font-family:arial,sans-serif;color:rgb(36,39,41);background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"> </span><span style="font-size:11.5pt;line-height:115%;font-family:arial,sans-serif;color:rgb(36,39,41);background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial">and the minimum value is<span class="gmail-apple-converted-space"> </span></span></span><code style="white-space:pre-wrap"><span style="font-size:10pt;line-height:115%;font-family:consolas;color:rgb(36,39,41);border:1pt none windowtext;padding:0in;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;background-color:rgb(239,240,241)">0.0. </span></code><span class="gmail-apple-converted-space"><span style="font-size:11.5pt;line-height:115%;font-family:arial,sans-serif;color:rgb(36,39,41);background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"> </span></span><span style="font-size:11.5pt;line-height:115%;font-family:arial,sans-serif;color:rgb(36,39,41);background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial">I saved it using<span class="gmail-apple-converted-space"> </span></span><code style="white-space:pre-wrap"><span style="font-size:10pt;line-height:115%;font-family:consolas;color:rgb(36,39,41);border:1pt none windowtext;padding:0in;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;background-color:rgb(239,240,241)">io.imsave(‘mask_image’,temp_mask)</span></code><span class="gmail-apple-converted-space"><span style="font-size:11.5pt;line-height:115%;font-family:arial,sans-serif;color:rgb(36,39,41);background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"> </span><span style="font-size:11.5pt;line-height:115%;font-family:arial,sans-serif;color:rgb(36,39,41);background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial">However, after I re-opened this image using<span class="gmail-apple-converted-space"> </span></span></span><code style="white-space:pre-wrap"><span style="font-size:10pt;line-height:115%;font-family:consolas;color:rgb(36,39,41);border:1pt none windowtext;padding:0in;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;background-color:rgb(239,240,241)">img_mask =
io.imread(‘mask_image’)</span></code><span style="font-size:11.5pt;line-height:115%;font-family:arial,sans-serif;color:rgb(36,39,41);background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial">. The read image turns out to  have type<span class="gmail-apple-converted-space"> </span></span><code style="white-space:pre-wrap"><span style="font-size:10pt;line-height:115%;font-family:consolas;color:rgb(36,39,41);border:1pt none windowtext;padding:0in;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;background-color:rgb(239,240,241)">unit16</span></code><span style="font-size:11.5pt;line-height:115%;font-family:arial,sans-serif;color:rgb(36,39,41);background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial">, the max value becomes<span class="gmail-apple-converted-space"> </span></span><code style="white-space:pre-wrap"><span style="font-size:10pt;line-height:115%;font-family:consolas;color:rgb(36,39,41);border:1pt none windowtext;padding:0in;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;background-color:rgb(239,240,241)">6553</span></code><span style="font-size:11.5pt;line-height:115%;font-family:arial,sans-serif;color:rgb(36,39,41);background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial">5 and the min value is<span class="gmail-apple-converted-space"> </span></span><code style="white-space:pre-wrap"><span style="font-size:10pt;line-height:115%;font-family:consolas;color:rgb(36,39,41);border:1pt none windowtext;padding:0in;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;background-color:rgb(239,240,241)">0</span></code><span class="gmail-apple-converted-space"><span style="font-size:11.5pt;line-height:115%;font-family:arial,sans-serif;color:rgb(36,39,41);background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"> .  It seems to me that io.imsave automatically transform the float32 array into an unit16 array.<span></span></span></span></p>

<p class="MsoNormal"><span style="font-size:11.5pt;line-height:115%;font-family:arial,sans-serif;color:rgb(36,39,41);background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial">Is it possible to save the image while keeping the original type? If not, what’s the correct way to save an image represented as an array, with type<span class="gmail-apple-converted-space"> </span></span><code style="white-space:pre-wrap"><span style="font-size:10pt;line-height:115%;font-family:consolas;color:rgb(36,39,41);border:1pt none windowtext;padding:0in;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;background-color:rgb(239,240,241)">float32</span></code><span style="font-size:11.5pt;line-height:115%;font-family:arial,sans-serif;color:rgb(36,39,41);background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"> and the range of value <code><span style="font-size:10pt;line-height:115%;font-family:consolas;border:1pt none windowtext;padding:0in;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial;background-color:rgb(239,240,241)">[0.0,1.0]</span></code><span style="font-size:11.5pt;line-height:115%;font-family:arial,sans-serif;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial">? </span><span></span></span></p><p class="MsoNormal"><span style="font-size:11.5pt;line-height:115%;font-family:arial,sans-serif;color:rgb(36,39,41);background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="font-size:11.5pt;line-height:115%;font-family:arial,sans-serif;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><br></span></span></p><p class="MsoNormal"><span style="font-size:11.5pt;line-height:115%;font-family:arial,sans-serif;color:rgb(36,39,41);background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial"><span style="font-size:11.5pt;line-height:115%;font-family:arial,sans-serif;background-image:initial;background-position:initial;background-size:initial;background-repeat:initial;background-origin:initial;background-clip:initial">Thank you very much!</span></span></p></div>