MATLAB相应一些函数机及其作用

时间:2020-11-30 21:31:37
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)相关命令:makelut2.bestblk功能:确定进行块操作的块大小.语法:siz = bestblk([m n],k)[mb,nb] = bestblk([m n],k)举例siz = bestblk([640 800],72)siz =64 50相关命令:blkproc3.blkprocMATLAB高级应用——图形及影像处理 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,inline4.brighten功能: 增加或降低颜色映像表的亮度.语法:brighten(beta)newmap = brighten(beta)newmap = brighten(map,beta)brighten(fig,beta)相关命令:imadjust, rgbplot5.bwarea功能: 计算二进制图像对象的面积.语法:total = bwarea(BW)举例BW = imread('circles.tif');imshow(BW);附录 MATLAB图像处理命令 321bwarea(BW)ans =15799相关命令:bweuler, bwperim6.bweuler.功能: 计算二进制图像的欧拉数.语法:eul = bweuler(BW,n)举例BW = imread('circles.tif');imshow(BW);bweuler(BW)ans =-2相关命令:bwmorph, bwperim7.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高级应用——图形及影像处理 322BW1 =[1 0 0 0 0 0 0 01 1 1 1 1 0 0 01 0 0 0 1 0 1 01 0 0 0 1 1 1 01 1 1 1 0 1 1 11 0 0 1 1 0 1 01 0 0 0 1 0 1 01 0 0 0 1 1 1 0]BW2 = bwfill(BW1,3,3,8)BW2 =1 0 0 0 0 0 0 01 1 1 1 1 0 0 01 1 1 1 1 0 1 01 1 1 1 1 1 1 01 1 1 1 0 1 1 11 0 0 1 1 0 1 01 0 0 0 1 0 1 01 0 0 0 1 1 1 0I = imread('blood1.tif');BW3 = ~im2bw(I);BW4 = bwfill(BW3,'holes');imshow(BW3)figure, imshow(BW4)相关命令:bwselect, roifill8.bwlabel功能:标注二进制图像中已连接的部分.语法:附录 MATLAB图像处理命令 323L = bwlabel(BW,n)[L,num] = bwlabel(BW,n)举例BW = [1 1 1 0 0 0 0 01 1 1 0 1 1 0 01 1 1 0 1 1 0 01 1 1 0 0 0 1 01 1 1 0 0 0 1 01 1 1 0 0 0 1 01 1 1 0 0 1 1 01 1 1 0 0 0 0 0]L = bwlabel(BW,4)L =1 1 1 0 0 0 0 01 1 1 0 2 2 0 01 1 1 0 2 2 0 01 1 1 0 0 0 3 01 1 1 0 0 0 3 01 1 1 0 0 0 3 01 1 1 0 0 3 3 01 1 1 0 0 0 0 0[r,c] = find(L==2);rc = [r c]rc =2 53 52 63 6相关命令:bweuler, bwselect9.bwmorph功能:提取二进制图像的轮廓.语法:BW2 = bwmorph(BW1,operation)BW2 = bwmorph(BW1,operation,n)举例BW1 = imread('circles.tif');MATLAB高级应用——图形及影像处理 324imshow(BW1);BW2 = bwmorph(BW1,'remove');BW3 = bwmorph(BW1,'skel',Inf);imshow(BW2)figure, imshow(BW3)相关命令:bweuler, bwperim, dilate, erode10.bwperim功能:计算二进制图像中对象的周长.语法:BW2 = bwperim(BW1,n)举例BW1 = imread('circbw.tif');BW2 = bwperim(BW1,8);imshow(BW1)figure, imshow(BW2)附录 MATLAB图像处理命令 325相关命令:bwarea, bweuler, bwfill11.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, roifill12.cmpermuteMATLAB高级应用——图形及影像处理 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);相关命令:randperm13.cmunique功能:查找颜色映像表中特定的颜色及相应的图像.语法:[Y,newmap] = cmunique(X,map)[Y,newmap] = cmunique(RGB)[Y,newmap] = cmunique(I)相关命令:gray2ind, rgb2ind14.col2im功能:将矩阵的列重新组织到块中.语法:A = col2im(B,[m n],[mm nn],block_type)A = col2im(B,[m n],[mm nn])相关命令:blkproc, colfilt, im2col, nlfilter15.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, nlfilter16.colorbar功能:显示颜色条.语法:colorbar('vert')colorbar('horiz')colorbar(h)colorbarh = colorbar(...)举例I = imread('blood1.tif');h = fspecial('log');I2 = filter2(h,I);imshow(I2,[]), colormap(jet(64)), colorbar17.conv2功能:进行二维卷积操作.语法:C = conv2(A,B)C = conv2(hcol,hrow,A)C = conv2(...,shape)举例A = magic(5)A =17 24 1 8 1523 5 7 14 164 6 13 20 22MATLAB高级应用——图形及影像处理 32810 12 19 21 3