MATLAB 图像处理命令 % imshow imshow 是用来显示图片的,如 >> I = imread('moon.tif'); >> figure,imshow(I); 而有时为了数据处理,要把读取的图片信息转化为更高的精度, >> I = double(imread('moon.tif')); 为了保证精度,经过了运算的图像矩阵 I 其数据类型会从 unit8 型变成 double 型。如果直接运行 imshow(I),我们会发现显示的是一个白色的图像。这是因为 imshow()显示图像时对 double 型是认为在 0~ 1 范围内,即大于 1 时都是显示为白色,而 imshow 显示 uint8型时是 0~ 255 范围。而经过运算的范围在 0-255 之间的 double 型数据就被不正常得显示为白色图像了。 有两个解决方法: 1> imshow(I/256); -----------将图像矩阵转化到 0-1 之间 2> imshow(I,[]); -----------自动调整数据的范围以便于显示. 从实验结果看两种方法都解决了问题,但是从显示的图像看,第二种方法显示的图像明暗黑白对比的强烈些! +++++++++++++++++++++++++++++++++++++++ IMSHOW(I) displays the grayscale image I. IMSHOW(I,[LOW HIGH]) displays the grayscale image I, specifying the display range for I in [LOW HIGH]. The value LOW (and any value less than LOW) displays as black, the value HIGH (and any value greater than HIGH) displays as white. Values in between are displayed as intermediate shades of gray,using the default number of gray levels. If you use an empty matrix ([]) for[LOW HIGH], IMSHOW uses [min(I(:)) max(I(:))]; that is, the minimum value in I is displayed as black, and the maximum value is displayed as white. +++++++++++++++++++++++++++++++++++++++ 图像为 y,为何用 imshow(uint8(y))和 imshow(y,[])时的图像显示结果不同? 回答: imshow(uint8(y))是按照 256 级灰度显示 y 得绝对数据。0 表示黑色,255 表示白色,y中大于 255 的值强制为 255。 imshow(y,[]),将 y 中的最小值看作 0(black),最大值看作 255(white) -->增加图像的对比度。 所以两者不同。 % padarray 功能:填充图像或填充数组。 用法:B = padarray(A,padsize,padval,direction) A 为输入图像,B 为填充后的图像, padsize ...