Displaying 16 bit images
35 views (last 30 days)
DGM on 8 Dec 2022
Edited: DGM on 8 Dec 2022
It's hard to know what you're doing wrong exactly since you didn't give a code example, but I'm going to guess.
Imshow() will display images of various classes so long as the image is scaled correctly with respect to its current class. If you have uint16 data cast as double, it won't be displayed as expected.
Alternatively, if you did something like this, you'll probably lose most of the image data due to truncation.
inpict = imread('myskeleton.tif'); % uint16 [0 65535]
inpict = uint8(inpict); % truncate everything above 255
When changing an image to another class, scale is important. Tools like uint8(), double(), etc. only cast the data. Tools like im2uint8(), im2double(), etc. rescale the data to fit the expected range of the destination class.
inpict = im2uint8(inpict); % rescale [0 65535] to fit within [0 255]
That avoids data truncation, and it keeps things scaled as other tools (imshow(), imwrite()) expect it.