Frustration with 12 bit images

Stefan van der Walt stefanv at berkeley.edu
Wed Jul 29 16:51:53 EDT 2015


Hi Johnny

On 2015-07-29 11:50:59, goettj at gmail.com wrote:
>     The input image data response to min and max make good 12bit 
>     sense, but  
> it is totally beyond me how I am getting 16bit responses for D 
> and E.

Your images are loaded in with dtype uint16, which has range 0 to 
65535 (even though your 12-bit max value is 4095).  So, when you 
subtract a value and it goes below 0, wraparound occurs:

In [2]: np.array([0, 1, 2], dtype=np.uint16) - 5 Out[2]: 
array([65531, 65532, 65533], dtype=uint16) 

One way to solve the problem is to first change the type of your 
images to np.int32 or np.int64.

Regards
Stéfan



More information about the scikit-image mailing list