MATLAB: Images don’t show with imshow after converting them to double.

convertdoubleimshow

Hello all,
I have a very simple code, pic.png is a greyscale image:
I = imread('pic.png');
imshow(I); %displays the picture without problems
I = double(I);
imshow(I) %only displays white, nothing more.
I find this weird, why does it do this?

Best Answer

MATLAB looks at the datatype to decide which range of values to expect. uint8 are expected to be 0 to 255. double are expected to be 0 to 1. When you double() a uint8 you end up with 0. to 255. and everyt value from 1 upwards will be considered to saturate the maximum 9 to 1 range.
You im2double() instead of double()