1、matlab图像处理常用函数列表docx附录MATLAB图像处理工具箱函数表1通用函数函数功能语法colorbar显示颜色条colorbar colorbar(./peeraxes_handle) colorbar(axes_handle) colorbalocation1)colorbar(./PropertyName*,property value) cbar_axes = colorbar()getimage从坐标轴取得图像数据A = getimage(h)x,y,A = getimage(h) .,A,flag = getimage(h) .=getimageimage创建并显示图像对
2、象image(C)image(x,y,C) image(./PropertyNameProperty Value,.) image(,PropertyNameProperty Value,.) Formal syntax - PN/PV onlyhandle = image()imagesc按图像显示数据矩阵imagesc(C) imagesc(x,y,C) imagesc(Qims) h = imagesc(.)imshow显示图像imshow(I,n) imshow(IJlow high) imshow(BW) imshow(X,map)imshow(RGB)imsho w(,displa
3、y_option) imshow(x,yA ) imshow filename h = imshow()imview利川图像浏览器显示图像imview(I)imview(RGB)imview(X,map)imview(I,range) imview(filename) imview(./InitialMagnificationinitial_mag) h = imview()imview close allmontage在矩形框中同时显示多帧图像montage(I) montage(BW) montage(X,map) montage(RGB) h = montage(.)immovie创建多
4、帧索引色图像的电影动画mov = immovie(X,map)mov = immovie(RGB)subimage在一个图形中显示多个图像,结合函数subplot使用subimage(X.map) subimage(I) subimage(BW) subimage(RGB) subimage(x,y.) h = subimage()truesize调整图像显示尺寸truesize(fig,mrows mcols)truesize(fig)wrap将图像显示到纹理映射农面warp(X.map) warp(I5n) warp(BW) warp(RGB) warp(z,.) warp(x,y,z,)
5、 h = warp(.)zoom onzoom offzoom outzoom resetzoomzoom xonzoom yon zoom(factor) zoom(fig, option)表2图像文件I/O函数函数功能语法imfinfo返回图像文件信息info = imfinfo(filename5fmt)info = imfinfo(filename)imread从图像文件中读取图像A = imread(filename,fmt)X,map = imread(filename,fmt).=imread(filename).=imread(URL,.)=imread(.,idx)(CUR,
6、 GIF, ICO, and TIFF only)=imread(., PixelRegion, ROWS,COLS ) (TIFF only).=imread(./framesidx) (GIF only).=imread(.,ref) (HDF only).=imread(./BackgroundColorBG)(PNG only)A,map,alpha = imread()(ICO, CUR, and PNG only)imwrite把图像写入图像文件中imwrite(A,filename,fmt)imwrite(X,map,filename,fmt)i m write(.,filena
7、me)imwrite(,Param 1 ,Vall f aram2,Val2 )表3空间变换函数函数功能语法findbounds为空间变换寻找输出边界outbounds = findbounds(TFORM,inbounds)fliptform切换空间变换结构的输入和输出角色TFLIP = fliptform(T)imcrop剪切图像12 = imcrop(I)X2 = imcrop(X,map)RGB2 = imcrop(RGB)12 = imcrop(I,rect)X2 = imcrop(X,map,rect)RGB2 = imcrop(RGB,rect) =imcrop(x,y,) A,
8、rectJ = imcrop() xyAject = imcrop()imresize图像缩放B = imresize(A,m)B = imresize( A,m,method)B = imresize(A,mrows ncols,method)B = imresize(.,method,n)B = imresize(,method,h)imrotate图像旋转B = imrotate(A,angle)B = imrotate(A,angle,method)B = imrotate(A,angle,method,bbox)interp22-D数据插值ZI = interp2(X,Y,Z,XI,
9、YI)ZI = interp2(Z,XI,YI)ZI = interp2(Z,ntimes)ZI = interp2(X,Y,Z,XI,YI,method)imtransform对图像进行2-D空间变换B = imtransform(A,TFORM)B = imtransform(A,TFORM,INTERP)B,X DATA, YD ATA = imtransform(.)B,X DATA, YD ATA = imtransform(.Mparam 1, vail, param2, val2,)makeresampler生成重采样结构R = makeresampler(interpolant
10、,padmethod)maketform生成几何变换结构T = maketform(transformtypev.)tformarray多维数组的空间变换B = tformarray(A, T, R, TDIMS_A,TDIMS_B, TSIZE_B, TMAP_B,F)tformfwd正向空1可变换X,Y = tformfwd(T,U,V)X1,X2,X3,. = tformfwd(T,U 1 ,U2,U3,.)X = tformfwd(T,U)X1,X2,X3,.二 tformfwd(T,U)X = tformfwd(T,Ul ,U2,U3,.)tforminv逆向空间变换U = tfor
11、minv(X,T)表4像素和统计处理函数函数功能语法corr2计算两个矩阵的2-D相关系数r = coit2(A,B)imcontour创建图像的轮廓图imcontour(I)imcontour(Ln) imcontour(Lv) imcontour(x,y,.) imcontour(.,LineSpec) C,h = imcontour()imhist显示图像的直方图imhist(I,n)imhist(X,map)counts,xj = imhist()impixel确定像素颜色值P = impixel(I)P = impixeI(X,map)P = impixel(RGB)P = impi
12、xel(I,c,r)P = impixel(X,map,c,r)P = impixeI(RGB,c,r)fc,r,Fl = impixel()P = impixel(x,y,xi,yi)P = impixel(x,y,X,map,xi,yi)P = impixel(x,y,RGB,xi,yi) xi,yi,P = impixel(x,y,)improfile沿线段计算剖面图的像索值c = improfilec = improfile(n)c = improfile(I,xi,yi)c = improfile(I,xi,yi,n)cx,cy,c = improfile() cx,cy,c,xi,
13、yi = improfile() .=improfile(x,yj,xi,yi) .=improfile(x,y,I,xi,yi,n) .=improfile(.,method)mean2求矩阵元素平均值B = mean2(A)pixval显示图像像素信息pixval onpixval offpixval pixval(fig,option) pixval(ax,option) pixval(H,option)regionprops得到图像区域属性STATS = regionprops(L,properties)std2计算矩阵元素的标准偏移b = std2(A)表5图像分析函数函数功能语法e
14、dge识别灰度图像中的边界BW = edged,sober)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,roberts1,thresh)BW,thresh = edgeCI/
15、roberts1,.)BW = edge(I;log)BW = edge(I,log,thresh)BW = edge(I,log*,thresh,sigma)BW,threshold = edge(I,log,.)qtdecomp执行四义树分解S = qtdecomp(I)S = qtdecomp(Lthreshold)S = qtdecomp(I,threshold jnindim)S = qtdecomp(I,threshold,mindim maxdim)S = qtdecomp(I,fun)S = qtdecomp(I,fun,Pl,P2,)qtgetblk获取四义树分解中的数组块值
16、vals,r,c = qtgetblk(I,S,dim)vals,idx = qtgetblk(I,S,dim)qtsetblk设置四叉树分解屮的数纽块值J = qtsetblk(LS,dim,vals)表6图像增强函数函数功能语法adaplhisteq执行对比度受限的宜方图均衡J = adapthisteq(I)J = adapthisteq(I,paraml,vall,param2,val2.)decorrstretch对多通道图像应用解卷积延拓S = decorrstretch(I)S = decorrstretch(I,TOL)histeq用直方图均等化增强对比度J = histeq(
17、Lhgram)J = histeq(I,n)J,T = histeq(I,.)n ewmap = histeq(X,map,hgram) n ewmap = histeq(X5map) newmap,T| = histeq(X,.)imadjust调整图像灰度值或颜色映射表J = imadjust(I)J = imadjust(I,low_in; high_in,low_out; high_out)J = i madj ust(.gamma)new map = imadjust(map, low _in high_in, low_out high_out, gamma)RGB2 = imadj
18、ust(RGBl,.)imnoise向图像中加入噪声J = imnoise(Ltype)J = imnoise(I,type,parameters)medfilt2进行二维中值滤波B = medfilt2(A,m n)B = medfilt2(A)B = medfilt2( A,indexed,.)ordfilt2进行二维统计顺序滤波B = ordfilt2( A,order,domain)B = ordfilt2( A,order,domain,S)B = ordfilt2(.,padopt)stretchlim得到图像对比度延拓的灰度上下限LOW_HIGH = stretchlim(I,T
19、OL)LOW_HIGH = stretchlim(RGB,TOL)wiener2进行二维适应性去噪滤波J = wiener2(IJm n,noise)J,noise = wiener2(I,m nJ)表7线性滤波函数函数功能语法conv2二维卷积C = conv2(A,B)C = conv2(hcol,hrow,A)C = conv2(./shape1)convmtx2二维矩阵卷积T = convmtx2(H,m,n)T = convmtx2(H,m n)convnn维卷积C = convn(A,B)C = con vn( A,B /shape1)filter2二维线性滤波Y = filter
20、2(h,X)Y = filter2(h,X,shape)fspecial创建预定义滤波器h = fspecial(type)h = fspecial(type,parameters)imfilter多维图像滤波B = imfi!ter(A,H)B = imfilter( A,H,option l,option2v)表8线性二维滤波器设计函数函数功能语法freqspace确定二维频率响应的频率空间fl ,f2 = freqspace(n) ffl,f2 = freqspace(m n) xl,yl = freqspace(./meshgricr) f = freqspace(N)f = freq
21、space(N/wholef)freqz2计算二维频率响应H,fl, f2 = freqz2(h,nl,n2)H,fl,f2 = freqz2(h,n2nl)H,fl,f2 = freqz2(h)H,fl,f2 = freqz2(h,fl,f2).=freqz2(h,.,dx dy).=freqz2(h,.,dx) freqz2(.)fsamp2用频率采样法设计二维FIR滤波器h = fsamp2(Hd)h = fsamp2(fl,f2,Hd,m nJ)ftrans2通过频率转换法设计二维FIR滤波器h = ftrans2(b,t)h = ftrans2(b)fwind 1用一维窗口方法设计二
22、维FIR滤波器h = fwind l(Hd,win)h = fwind 1 (Hd,win 1 ,win2)h = fwind l(fl,f2,Hd,.)fwind2用二维窗口方法设计二维FIR滤波器h = fwind2(Hd,win)h = fwind2(f 1 ,f2,Hd, win)表9图像变换函数函数功能语法dct2进行二维离散余弦变换B = dct2(A)B = dct2(A,m,n)B = dct2(A,m n)dctmtx计算离散余弦变换矩阵D = dctmtx(n)fft2进行二维快速傅立叶变换Y = fft2(X)Y = fft2(X,m,n)fftn进行n维快速傅立叶变换Y
23、 = fftn(X)Y = fftn(X,siz)fftshift转换快速傅立叶变换的输出象限Y = fftshift(X)Y = ff(shift(X,dim)idct2计算二维逆离散余弦变换B = idct2(A)B = idct2(A,m,n)B = idct2(A,m nJ)ifft2计算二维逆快速傅立叶变换Y = ifft2(X)Y = ifft2(X,m,n)y = ifft2(., nonsymmetric1)y = ifft2(., nonsymmetric1)ifftn计算n维逆快速傅立叶变换Y = ifftn(X)Y = ifftn(X,siz)y = onsymmetri
24、c1)y = onsymmetric1)iradon逆Radon变换I = iradon(R,theta)I = iradon(R, theta, interp, filter,frequency_scaling, output_size)I,H = iradon(.)phantom产生一个头部幻影图像P = phantom(def,n)P = phantom(E,n)P,E = phantom()radon计算Radon变换R=radon(I,theta)R,xp=radon(.)F = fanbeam(I,D)fanbeam计算扇形投影变换F = fanbeam(.,param 1 ,va
25、l 1,param 1 ,val2,.) Esensor_positions,fan_rotation_angles fanbeam()表10边沿和块处理函数函数功能语法bestblk确定进行块操作的块人小siz = bestblk(m n,k)mb,nbj = bestblk(m n,k)blkproc实现图像的非重叠(distinct)块操作B = blkproc(A,m n,fun)B = blkproc(A,m n,fun,Pl,P2,.)B=blkproc(A,m n,mborder nborder, fun,)B = blkproc(A/indexed.)col2im将矩阵的列重新
26、组织到块中A = col2im(B,m n,mm nnj, block_type)A = col2im(B,m nn)colfilt利用列相关两数进行边沿操作B = colfilt(A,m n,block_type,fun)B = colfilt(A,m n,block_type,fun,P 1 ,P2,.)B = colfilt(A, m n, mblock nblock, block_type, fun,)B = colfill(A,indexed,.)im2col重调图像块为列B = im2col(A,m nj,block_type)B = im2col(A,m nJ)B = im2co
27、l(A,indexed;)nlfilter通用滑动邻域操作B = nlfilter(A,m n,fun)B = nlfilter(A,m n,fun,Pl,P2,.)B = nlfilter( A,indexed,.)表11图像形态学操作函数函数功能语法applylut在二值图像屮利用查找表进行邻域操作A = applylut(BW,LUT)bwarea计算二值图像的对象面积total = bwarea(BW)bweuler计算二值图像的欧拉数eul = bweuler(BW.n)bwhitmiss执行二值图像的击中和击不中操作BW2 = bwhitmiss(BWl,SEl,SE2)BW2 =
28、 bwhitmiss(B W1JNTERVAL)bwlabel标注二值图像中己连接的部分L = bwlabel(BW,n)L,num = bwlabel(BW,n)bwmorph二值图像的通用形态学操作BW2 = bwmorph(BW,operation)BW2 = bwmorph(BW,operation)bwperim计算二值图像中对象的周长BW2 = bwperim(BWl)BW2 = bwperim(BWl,CONN)bwselect在二值图像中选择对象BW2 = bwselect(BW,c,r,n)BW2 = bwselect(BW,n)BW2,idx = bwselect(.)BW2 = bwselect(x,y,BW,xi,yi,n)x,y,BW2,idx,xi,yi = bwselect(.)makelut创建用于applylut函数的查找表lut = makelut(fun.n)lut = makelut(fun,n,P 1 ,
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1