![]() |
#2
wangyou66992007-01-03 14:04
8.bwlabel
功能: 标注二进制图像中已连接的部分. 语法: 附录 MATLAB图像处理命令 323 L = bwlabel(BW,n) [L,num] = bwlabel(BW,n) 举例 BW = [1 1 1 0 0 0 0 0 1 1 1 0 1 1 0 0 1 1 1 0 1 1 0 0 1 1 1 0 0 0 1 0 1 1 1 0 0 0 1 0 1 1 1 0 0 0 1 0 1 1 1 0 0 1 1 0 1 1 1 0 0 0 0 0] L = bwlabel(BW,4) L = 1 1 1 0 0 0 0 0 1 1 1 0 2 2 0 0 1 1 1 0 2 2 0 0 1 1 1 0 0 0 3 0 1 1 1 0 0 0 3 0 1 1 1 0 0 0 3 0 1 1 1 0 0 3 3 0 1 1 1 0 0 0 0 0 [r,c] = find(L==2); rc = [r c] rc = 2 5 3 5 2 6 3 6 相关命令: bweuler, bwselect 9.bwmorph 功能: 提取二进制图像的轮廓. 语法: BW2 = bwmorph(BW1,operation) BW2 = bwmorph(BW1,operation,n) 举例 BW1 = imread('circles.tif'); MATLAB高级应用——图形及影像处理 324 imshow(BW1); BW2 = bwmorph(BW1,'remove'); BW3 = bwmorph(BW1,'skel',Inf); imshow(BW2) figure, imshow(BW3) 相关命令: bweuler, bwperim, dilate, erode 10.bwperim 功能: 计算二进制图像中对象的周长. 语法: BW2 = bwperim(BW1,n) 举例 BW1 = imread('circbw.tif'); BW2 = bwperim(BW1,8); imshow(BW1) figure, imshow(BW2) 附录 MATLAB图像处理命令 325 相关命令: bwarea, bweuler, bwfill 11.bwselect 功能: 在二进制图像中选择对象. 语法: BW2 = bwselect(BW1,c,r,n) BW2 = bwselect(BW1,n) [BW2,idx] = bwselect(...) 举例 BW1 = imread('text.tif'); c = [16 90 144]; r = [85 197 247]; BW2 = bwselect(BW1,c,r,4); imshow(BW1) figure, imshow(BW2) 相关命令: bwfill, bwlabel, impixel, roipoly, roifill 12.cmpermute MATLAB高级应用——图形及影像处理 326 功能: 调整颜色映像表中的颜色. 语法: [Y,newmap] = cmpermute(X,map) [Y,newmap] = cmpermute(X,map,index) 举例 To order a colormap by luminance, use: ntsc = rgb2ntsc(map); [dum,index] = sort(ntsc(:,1)); [Y,newmap] = cmpermute(X,map,index); 相关命令: randperm 13.cmunique 功能: 查找颜色映像表中特定的颜色及相应的图像. 语法: [Y,newmap] = cmunique(X,map) [Y,newmap] = cmunique(RGB) [Y,newmap] = cmunique(I) 相关命令: gray2ind, rgb2ind 14.col2im 功能: 将矩阵的列重新组织到块中. 语法: A = col2im(B,[m n],[mm nn],block_type) A = col2im(B,[m n],[mm nn]) 相关命令: blkproc, colfilt, im2col, nlfilter 15.colfilt 功能: 利用列相关函数进行边沿操作. 语法: B = colfilt(A,[m n],block_type,fun) B = colfilt(A,[m n],block_type,fun,P1,P2,...) B = colfilt(A,[m n],[mblock nblock],block_type,fun,...) B = colfilt(A,'indexed',...) 附录 MATLAB图像处理命令 327 相关命令: blkproc, col2im, im2col, nlfilter 16.colorbar 功能: 显示颜色条. 语法: colorbar('vert') colorbar('horiz') colorbar(h) colorbar h = colorbar(...) 举例 I = imread('blood1.tif'); h = fspecial('log'); I2 = filter2(h,I); imshow(I2,[]), colormap(jet(64)), colorbar 17.conv2 功能: 进行二维卷积操作. 语法: C = conv2(A,B) C = conv2(hcol,hrow,A) C = conv2(...,shape) 举例 A = magic(5) A = 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 MATLAB高级应用——图形及影像处理 328 10 12 19 21 3 11 18 25 2 9 B = [1 2 1;0 2 0;3 1 3] B = 1 2 1 0 2 0 3 1 3 C = conv2(A,B) C = 17 58 66 34 32 38 15 23 85 88 35 67 76 16 55 149 117 163 159 135 67 79 78 160 161 187 129 51 23 82 153 199 205 108 75 30 68 135 168 91 84 9 33 65 126 85 104 15 27 相关命令: filter2 18.convmtx2 功能: 计算二维卷积矩阵. 语法: T = convmtx2(H,m,n) T = convmtx2(H,[m n]) 相关命令: conv2 19.convn 功能: 计算n维卷积. 语法: C = convn(A,B) C = convn(A,B,shape) 相关命令: conv2 20.corr2 功能: 计算两个矩阵的二维相关系数. 附录 MATLAB图像处理命令 329 语法: r = corr2(A,B) 相关命令: std2 21.dct2 功能: 进行二维离散余弦变换. 语法: B = dct2(A) B = dct2(A,m,n) B = dct2(A,[m n]) 举例 RGB = imread('autumn.tif'); I = rgb2gray(RGB); J = dct2(I); imshow(log(abs(J)),[]), colormap(jet(64)), colorbar J(abs(J) < 10) = 0; K = idct2(J)/255; imshow(K) 相关命令: fft2, idct2, ifft2 22.dctmtx 功能: MATLAB高级应用——图形及影像处理 330 计算离散余弦变换矩阵. 语法: D = dctmtx(n) 相关命令: dct2 23.dilate 功能: 放大二进制图像. 语法: BW2 = dilate(BW1,SE) BW2 = dilate(BW1,SE,alg) BW2 = dilate(BW1,SE,...,n) 举例 BW1 = imread('text.tif'); SE = ones(6,2); BW2 = dilate(BW1,SE); imshow(BW1) figure, imshow(BW2) 相关命令: bwmorph, erode 24.dither 功能: 通过抖动增加外观颜色分辨率,转换图像. 语法: X = dither(RGB,map) BW = dither(I) 相关命令: rgb2ind 25.double 附录 MATLAB图像处理命令 331 功能: 转换数据为双精度型. 语法: B = double(A) 举例 A = imread('saturn.tif'); B = sqrt(double(A)); 相关命令: im2double, im2uint, uint8 26.edge 功能: 识别强度图像中的边界. 语法: BW = edge(I,'sobel') BW = edge(I,'sobel',thresh) BW = edge(I,'sobel',thresh,direction) [BW,thresh] = edge(I,'sobel',...) BW = edge(I,'prewitt') BW = edge(I,'prewitt',thresh) BW = edge(I,'prewitt',thresh,direction) [BW,thresh] = edge(I,'prewitt',...) BW = edge(I,'roberts') BW = edge(I,'roberts',thresh) [BW,thresh] = edge(I,'roberts',...) BW = edge(I,'log') BW = edge(I,'log',thresh) BW = edge(I,'log',thresh,sigma) [BW,threshold] = edge(I,'log',...) BW = edge(I,'zerocross',thresh,h) [BW,thresh] = edge(I,'zerocross',...) BW = edge(I,'canny') BW = edge(I,'canny',thresh) BW = edge(I,'canny',thresh,sigma) MATLAB高级应用——图形及影像处理 332 [BW,threshold] = edge(I,'canny',...) 举例 I = imread('rice.tif'); BW1 = edge(I,'prewitt'); BW2 = edge(I,'canny'); imshow(BW1); figure, imshow(BW2) 27.erode 功能: 弱化二进制图像的边界. 语法: BW2 = erode(BW1,SE) BW2 = erode(BW1,SE,alg) BW2 = erode(BW1,SE,...,n) 举例 BW1 = imread('text.tif'); SE = ones(3,1); BW2 = erode(BW1,SE); imshow(BW1) figure, imshow(BW2) 相关命令: bwmorph, dilate 附录 MATLAB图像处理命令 333 |
http://www.bbs.stu.edu.cn/cgi-bin/bbscon?board=MathTools&file=M.1150025394.A&num=3166
http://www.bbs.stu.edu.cn/cgi-bin/bbstcon?board=MathTools&file=M.1150025420.A
1.applylut
功能:
在二进制图像中利用lookup表进行边沿操作.
语法:
A = applylut(BW,lut)
举例
lut = makelut('sum(x(:)) == 4',2);
BW1 = imread('text.tif');
BW2 = applylut(BW1,lut);
imshow(BW1)
figure, imshow(BW2)
相关命令:
makelut
2.bestblk
功能:
确定进行块操作的块大小.
语法:
siz = bestblk([m n],k)
[mb,nb] = bestblk([m n],k)
举例
siz = bestblk([640 800],72)
siz =
64 50
相关命令:
blkproc
3.blkproc
功能:
MATLAB高级应用——图形及影像处理 320
实现图像的显式块操作.
语法:
B = blkproc(A,[m n],fun)
B = blkproc(A,[m n],fun,P1,P2,...)
B = blkproc(A,[m n],[mborder nborder],fun,...)
B = blkproc(A,'indexed',...)
举例
I = imread('alumgrns.tif');
I2 = blkproc(I,[8 8],'std2(x)*ones(size(x))');
imshow(I)
figure, imshow(I2,[]);
相关命令:
colfilt, nlfilter,inline
4.brighten
功能:
增加或降低颜色映像表的亮度.
语法:
brighten(beta)
newmap = brighten(beta)
newmap = brighten(map,beta)
brighten(fig,beta)
相关命令:
imadjust, rgbplot
5.bwarea
功能:
计算二进制图像对象的面积.
语法:
total = bwarea(BW)
举例
BW = imread('circles.tif');
imshow(BW);
附录 MATLAB图像处理命令 321
bwarea(BW)
ans =
15799
相关命令:
bweuler, bwperim
6.bweuler.
功能:
计算二进制图像的欧拉数.
语法:
eul = bweuler(BW,n)
举例
BW = imread('circles.tif');
imshow(BW);
bweuler(BW)
ans =
-2
相关命令:
bwmorph, bwperim
7.bwfill
功能:
填充二进制图像的背景色.
语法:
BW2 = bwfill(BW1,c,r,n)
BW2 = bwfill(BW1,n)
[BW2,idx] = bwfill(...)
BW2 = bwfill(x,y,BW1,xi,yi,n)
[x,y,BW2,idx,xi,yi] = bwfill(...)
BW2 = bwfill(BW1,'holes',n)
[BW2,idx] = bwfill(BW1,'holes',n)
举例
MATLAB高级应用——图形及影像处理 322
BW1 =[1 0 0 0 0 0 0 0
1 1 1 1 1 0 0 0
1 0 0 0 1 0 1 0
1 0 0 0 1 1 1 0
1 1 1 1 0 1 1 1
1 0 0 1 1 0 1 0
1 0 0 0 1 0 1 0
1 0 0 0 1 1 1 0]
BW2 = bwfill(BW1,3,3,8)
BW2 =
1 0 0 0 0 0 0 0
1 1 1 1 1 0 0 0
1 1 1 1 1 0 1 0
1 1 1 1 1 1 1 0
1 1 1 1 0 1 1 1
1 0 0 1 1 0 1 0
1 0 0 0 1 0 1 0
1 0 0 0 1 1 1 0
I = imread('blood1.tif');
BW3 = ~im2bw(I);
BW4 = bwfill(BW3,'holes');
imshow(BW3)
figure, imshow(BW4)
相关命令:
bwselect, roifill
[此贴子已经被作者于2007-1-3 14:09:41编辑过]