简体   繁体   English

使用imshow时uint8和双重图像之间的区别

[英]The difference between uint8 and double images when using imshow

The following code snippet results a double image . 下面的代码片段产生了double 图像

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

whereas, this other code snippet results a uint8 image . 而此其他代码段将生成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? 在显示这两个图形时,使用imshow的这两个图像的显示结果不同,但是造成这种差异的原因是什么?

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. 假设double类型的图像的值介于0到1之间,而uint8图像的值则假定介于0到255之间。由于double数据包含的值介于0到255之间(因为您只是将其强制转换为double而不执行任何缩放比例),由于大多数值都大于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 ,表明你想忽略这个假设和自动缩放显示的数据的动态范围

imshow(h, [])

Or you can normalize the double version using mat2gray prior to displaying the image 或者,您可以在显示图像之前使用mat2gray来标准化double版本

h = mat2gray(h);
imshow(h)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM