二 值 图像数组大小:m×n 图 图像元素值:0或1 像 图像数组大小:m×n 图像元素值:0或1
四、图像显示
Matlab的图像显示函数主要有imshow、colorbar和subimage三个。 1、imshow(I,n)
显示灰度级为n的图像,n缺省为256。 【例】按256灰度级显示
I=imread('moon.tif'); imshow(I,256) colorbar
图像显示 -6-
250200150100500 【例】按8灰度级显示 I=imread('moon.tif'); imshow(I,8) colorbar 250200150100500 2、imshow(I,[low,high]) 以灰度范围[low,high]显示图像,如果不知道灰度范围,可以用imshow(I,[])显示。
【例】按最大灰度范围显示
I=imread('moon.tif'); imshow(I,[]) colorbar
图像显示 -7-
250200150100500 【例】按指定灰度范围显示 I=imread('moon.tif'); imshow(I,[64,128]) colorbar 120110100908070 3、imshow(BW) 显示二值图像。
【例】双精度灰度图像
bw1=zeros(100,100); bw1(2:2:98,2:2:98)=1; imshow(bw1); whos bw1
Name Size Bytes Class
bw1 100x100 80000 double array Grand total is 10000 elements using 80000 bytes
图像显示 -8-
【例】8位的灰度图像
bw1=zeros(100,100); bw1(2:2:98,2:2:98)=1; bw2=uint8(bw1); imshow(bw2,[]); colorbar whos bw2
Name Size Bytes Class
bw2 100x100 10000 uint8 array Grand total is 10000 elements using 10000 bytes 10.90.80.70.60.50.40.30.20.10 【例】二值图像 bw1=zeros(100,100); bw1(2:2:98,2:2:98)=1; bw2=uint8(bw1); bw3=bw2~=0; imshow(bw3);
图像显示 -9-
whos bw3
Name Size Bytes Class
bw3 100x100 10000 logical array Grand total is 10000 elements using 10000 bytes
【例】显示二值图像
BW=imread('circles.tif'); imshow(BW);
【例】取反显示二值图像
BW=imread('circles.tif'); imshow(~BW);
图像显示 -10-