最新matlab中imshow(I-[low-high])的等效函数.doc
Four short words sum up what has lifted most successful individuals above the crowd: a little bit more.-author-datematlab中imshow(I-low-high)的等效函数关于matlab中imshow(I,low,high)的理解matlab中imshow(I,low,high)的等效函数在matlab中,imshow用于显示图像,而指令imshow(I,low,high)是将原图像中灰度值小于等于low的像素点置灰度值为0,原图像中灰度值大于等于high的像素点置灰度值为255,其余通过特定的映射进行变换。初始以为这个特定的映射只是这样:在low和high之间的像素点的灰度值保留原值不变。故而采用如下等价函数验证:function L = M_binaryzation(I,low,high )%L = M_binaryzation(I,low,high )% 这是imshow(I,low,high)的等价函数row,col=size(I);L=uint8(zeros(row,col);for i=1:rowfor j=1:colif I(i,j)>=highL(i,j)=255;elseif I(i,j)<=lowL(i,j)=0;elseL(i,j)=I(i,j);%原灰度值映射endendendend在工作空间上运行如下代码:I=imread('cameraman.tif');L=M_binaryzation(I,100,200);figure(1);imshow(I,100,200);xlabel('imshow(I,100,200)');figure(2);imshow(L);xlabel('imshow(L)');得到如下结果:显然两幅图并不一致,故而,imshow(I,low,high)里面的映射并非是直接使用原灰度值。考虑到一副灰度图像其一共可取有0-255共256个灰度值,而经过上述变换,只能取0,lowhigh,255一共N=high-low+1个灰度值(N<256),故而,可考虑这种映射是将low和high之间的灰度值映射到0255这个空间上,使其可取256个灰度值。如有一点的灰度值为105(设low=100,high=200),则映射到0255上,该点的灰度值为。用如下等价函数验证:function L = M_binaryzation(I,low,high )%L = M_binaryzation(I,low,high )% 这是imshow(I,low,high)的等价函数row,col=size(I);L=uint8(zeros(row,col);for i=1:rowfor j=1:colif I(i,j)>=highL(i,j)=255;elseif I(i,j)<=lowL(i,j)=0;elseL(i,j)=floor(I(i,j)-low)*(255/(high-low-1);%灰度空间扩展映射endendendend在工作空间上运行如下代码:I=imread('cameraman.tif');L=M_binaryzation(I,100,200);figure(1);imshow(I,100,200);xlabel('imshow(I,100,200)');figure(2);imshow(L);xlabel('imshow(L)');得到如下结果:显然,第种映射方法得出来的图像结果与imshow(I,100,200)的结果一致,结论:imshow(I,low,high)显示图像时是将原图像中灰度值小于等于low的像素点置灰度值为0,原图像中灰度值大于等于high的像素点置灰度值为255,其余通过特定的映射进行变换。映射方式是将lowhigh上的灰度值线性扩展到0255内。-