The difference between uint8 and double images when using imshow

雨燕双飞 提交于 2019-12-04 05:39:37

问题


The following code snippet results a double image.

f = imread('C:\Users\Administrator\Desktop\2.tif');
h = double(f);
figure;
imshow(h);

whereas, this other code snippet results a uint8 image.

f = imread('C:\Users\Administrator\Desktop\2.tif');
figure;
imshow(f);

While displaying these two figures, the displayed results of these two images using imshow are different, but what is the reason behind this difference?


回答1:


Images of type double are assumed to have values between 0 and 1 and uint8 images are assumed to have values between 0 and 255. Since your double data contains values between 0 and 255 (since you simply cast it as a double and don't perform any scaling), it will appear as mostly white since most values are greater than 1.

You can use the second input to imshow to indicate that you would like to ignore this assumption and automatically scale the display to the dynamic range of the data

imshow(h, [])

Or you can normalize the double version using mat2gray prior to displaying the image

h = mat2gray(h);
imshow(h)


来源:https://stackoverflow.com/questions/41561284/the-difference-between-uint8-and-double-images-when-using-imshow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!