收藏 分享(赏)

MATLAB7基本函数.doc

上传人:hwpkd79526 文档编号:7468831 上传时间:2019-05-19 格式:DOC 页数:14 大小:260KB
下载 相关 举报
MATLAB7基本函数.doc_第1页
第1页 / 共14页
MATLAB7基本函数.doc_第2页
第2页 / 共14页
MATLAB7基本函数.doc_第3页
第3页 / 共14页
MATLAB7基本函数.doc_第4页
第4页 / 共14页
MATLAB7基本函数.doc_第5页
第5页 / 共14页
点击查看更多>>
资源描述

1、MATLAB 图像处理工具箱函数第 1 页 共 14 页MATLAB 图像处理工具箱函数表 1 通用函数函数 功能 语法colorbar 显示颜色条colorbarcolorbar(.,peer,axes_handle)colorbar(axes_handle)colorbar(location)colorbar(.,PropertyName,propertyvalue)cbar_axes = colorbar(.)getimage 从坐标轴取得图像数据A = getimage(h)x,y,A = getimage(h).,A,flag = getimage(h). = getimageima

2、ge 创建并显示图像对象image(C)image(x,y,C)image(.,PropertyName,PropertyValue,.)image(PropertyName,PropertyValue,.) Formal syntax - PN/PV onlyhandle = image(.)imagesc 按图像显示数据矩阵imagesc(C)imagesc(x,y,C)imagesc(.,clims)h = imagesc(.)imshow 显示图像imshow(I,n)imshow(I,low high)imshow(BW)imshow(X,map)imshow(RGB)imshow(

3、,display_option)imshow(x,y,A,)imshow filenameh = imshow()imview 利用图像浏览器显示图像imview(I)imview(RGB)imview(X,map)imview(I,range)imview(filename)MATLAB 图像处理工具箱函数第 2 页 共 14 页imview(.,InitialMagnification,initial_mag)h = imview(.)imview close allmontage在矩形框中同时显示多帧图像montage(I)montage(BW)montage(X,map)montage

4、(RGB)h = montage(.)immovie创建多帧索引色图像的电影动画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(I,n)warp(BW)warp(

5、RGB)warp(z,.)warp(x,y,z,.)h = warp(.)zoom 缩放图像或图形zoom on zoom offzoom outzoom resetzoomzoom xonzoom yonzoom(factor)zoom(fig, option)表 2 图像文件 I/O 函数函数 功能 语法imfinfo 返回图像文件信息 info = imfinfo(filename,fmt)MATLAB 图像处理工具箱函数第 3 页 共 14 页info = imfinfo(filename)imread 从图像文件中读取图像A = imread(filename,fmt)X,map =

6、 imread(filename,fmt). = imread(filename). = imread(URL,.). = imread(.,idx) (CUR, GIF, ICO, and TIFF only). = imread(., PixelRegion, ROWS, COLS ) (TIFF only). = imread(.,frames,idx) (GIF only). = imread(.,ref) (HDF only). = imread(.,BackgroundColor,BG) (PNG only)A,map,alpha = imread(.) (ICO, CUR, an

7、d PNG only)imwrite 把图像写入图像文件中imwrite(A,filename,fmt)imwrite(X,map,filename,fmt)imwrite(.,filename)imwrite(.,Param1,Val1,Param2,Val2.)表 3 空间变换函数函数 功能 语法findbounds 为空间变换寻找输出边界 outbounds = findbounds(TFORM,inbounds)fliptform切换空间变换结构的输入和输出角色TFLIP = fliptform(T)imcrop 剪切图像I2 = imcrop(I)X2 = imcrop(X,map)

8、RGB2 = imcrop(RGB)I2 = imcrop(I,rect)X2 = imcrop(X,map,rect)RGB2 = imcrop(RGB,rect). = imcrop(x,y,.)A,rect = imcrop(.)x,y,A,rect = imcrop(.)imresize 图像缩放B = imresize(A,m)B = imresize(A,m,method)B = imresize(A,mrows ncols,method)B = imresize(.,method,n)MATLAB 图像处理工具箱函数第 4 页 共 14 页B = imresize(.,metho

9、d,h)imrotate 图像旋转B = imrotate(A,angle)B = imrotate(A,angle,method)B = imrotate(A,angle,method,bbox)interp2 2-D 数据插值ZI = interp2(X,Y,Z,XI,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,XD

10、ATA,YDATA = imtransform(.)B,XDATA,YDATA = imtransform(., param1, val1, param2, val2,.)makeresampler 生成重采样结构 R = makeresampler(interpolant,padmethod)maketform 生成几何变换结构 T = maketform(transformtype,.)tformarray 多维数组的空间变换B = tformarray(A, T, R, TDIMS_A, TDIMS_B, TSIZE_B, TMAP_B,F)tformfwd 正向空间变换X,Y = tf

11、ormfwd(T,U,V)X1,X2,X3,. = tformfwd(T,U1,U2,U3,.)X = tformfwd(T,U)X1,X2,X3,. = tformfwd(T,U)X = tformfwd(T,U1,U2,U3,.)tforminv 逆向空间变换 U = tforminv(X,T)表 4 像素和统计处理函数函数 功能 语法corr2计算两个矩阵的 2-D 相关系数r = corr2(A,B)imcontour 创建图像的轮廓图imcontour(I)imcontour(I,n)imcontour(I,v)imcontour(x,y,.)imcontour(.,LineSpec

12、)C,h = imcontour(.)imhist 显示图像的直方图imhist(I,n)imhist(X,map)counts,x = imhist(.)impixel 确定像素颜色值 P = impixel(I)MATLAB 图像处理工具箱函数第 5 页 共 14 页P = impixel(X,map)P = impixel(RGB)P = impixel(I,c,r)P = impixel(X,map,c,r)P = impixel(RGB,c,r)c,r,P = impixel(.)P = impixel(x,y,I,xi,yi)P = impixel(x,y,X,map,xi,yi)

13、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,yi = improfile(.). = improfile(x,y,I,xi,yi). = improfile(x,y,I,xi,yi,n). = improfile(.,method)mean2 求矩阵元素平均值 B = mean2(A

14、)pixval 显示图像像素信息pixval onpixval offpixvalpixval(fig,option)pixval(ax,option)pixval(H,option)regionprops 得到图像区域属性 STATS = regionprops(L,properties)std2 计算矩阵元素的标准偏移 b = std2(A)表 5 图像分析函数函数 功能 语法edge 识别灰度图像中的边界BW = edge(I,sobel)BW = edge(I,sobel,thresh)BW = edge(I,sobel,thresh,direction)BW,thresh = edg

15、e(I,sobel,.)BW = edge(I,prewitt)BW = edge(I,prewitt,thresh)BW = edge(I,prewitt,thresh,direction)BW,thresh = edge(I,prewitt,.)MATLAB 图像处理工具箱函数第 6 页 共 14 页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,

16、threshold = edge(I,log,.)qtdecomp 执行四叉树分解S = qtdecomp(I)S = qtdecomp(I,threshold)S = qtdecomp(I,threshold,mindim)S = qtdecomp(I,threshold,mindim maxdim)S = qtdecomp(I,fun)S = qtdecomp(I,fun,P1,P2,.)qtgetblk获取四叉树分解中的数组块值vals,r,c = qtgetblk(I,S,dim)vals,idx = qtgetblk(I,S,dim)qtsetblk设置四叉树分解中的数组块值J =

17、qtsetblk(I,S,dim,vals)表 6 图像增强函数函数 功能 语法adapthisteq执行对比度受限的直方图均衡J = adapthisteq(I)J = adapthisteq(I,param1,val1,param2,val2.)decorrstretch对多通道图像应用解卷积延拓S = decorrstretch(I)S = decorrstretch(I,TOL)histeq 用直方图均等化增强对比度J = histeq(I,hgram)J = histeq(I,n)J,T = histeq(I,.)newmap = histeq(X,map,hgram)newmap

18、= histeq(X,map)newmap,T = histeq(X,.)imadjust调整图像灰度值或颜色映射表J = imadjust(I)J = imadjust(I,low_in; high_in,low_out; high_out)J = imadjust(.,gamma)newmap = imadjust(map, low_in high_in, low_out high_out, gamma)RGB2 = imadjust(RGB1,.)imnoise 向图像中加入噪声 J = imnoise(I,type)MATLAB 图像处理工具箱函数第 7 页 共 14 页J = imn

19、oise(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,TOL)LOW_HIGH = stretchlim(RGB,TOL)wiener2 进行二维适应性去噪滤波

20、J = wiener2(I,m n,noise)J,noise = wiener2(I,m n)表 7 线性滤波函数函数 功能 语法conv2 二维卷积C = conv2(A,B)C = conv2(hcol,hrow,A)C = conv2(.,shape)convmtx2 二维矩阵卷积T = convmtx2(H,m,n)T = convmtx2(H,m n)convn n 维卷积C = convn(A,B)C = convn(A,B,shape)filter2 二维线性滤波Y = filter2(h,X)Y = filter2(h,X,shape)fspecial 创建预定义滤波器h =

21、 fspecial(type)h = fspecial(type,parameters)imfilter 多维图像滤波B = imfilter(A,H)B = imfilter(A,H,option1,option2,.)表 8 线性二维滤波器设计函数函数 功能 语法freqspace确定二维频率响应的频率空间f1,f2 = freqspace(n)f1,f2 = freqspace(m n)x1,y1 = freqspace(.,meshgrid)f = freqspace(N)f = freqspace(N,whole)freqz2 计算二维频率响应H,f1,f2 = freqz2(h,n

22、1,n2)H,f1,f2 = freqz2(h,n2 n1)H,f1,f2 = freqz2(h)H,f1,f2 = freqz2(h,f1,f2)MATLAB 图像处理工具箱函数第 8 页 共 14 页. = freqz2(h,.,dx dy). = freqz2(h,.,dx)freqz2(.)fsamp2用频率采样法设计二维 FIR滤波器h = fsamp2(Hd)h = fsamp2(f1,f2,Hd,m n)ftrans2通过频率转换法设计二维FIR 滤波器h = ftrans2(b,t)h = ftrans2(b)fwind1用一维窗口方法设计二维FIR 滤波器h = fwind1

23、(Hd,win)h = fwind1(Hd,win1,win2)h = fwind1(f1,f2,Hd,.)fwind2用二维窗口方法设计二维FIR 滤波器h = fwind2(Hd,win)h = fwind2(f1,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 = fftn(X)Y =

24、fftn(X,siz)fftshift转换快速傅立叶变换的输出象限Y = fftshift(X)Y = fftshift(X,dim)idct2 计算二维逆离散余弦变换B = idct2(A)B = idct2(A,m,n)B = idct2(A,m n)ifft2 计算二维逆快速傅立叶变换Y = ifft2(X)Y = ifft2(X,m,n)y = ifft2(., nonsymmetric)y = ifft2(., nonsymmetric)ifftn 计算 n 维逆快速傅立叶变换Y = ifftn(X)Y = ifftn(X,siz)y = ifftn(., nonsymmetric)

25、y = ifftn(., nonsymmetric)iradon 逆 Radon 变换I = iradon(R,theta)I = iradon(R, theta, interp, filter, MATLAB 图像处理工具箱函数第 9 页 共 14 页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()fanbeam 计算扇形投影

26、变换F = fanbeam(I,D)F = fanbeam(.,param1,val1,param1,val2,.)F,sensor_positions,fan_rotation_angles = fanbeam(.)表 10 边沿和块处理函数函数 功能 语法bestblk 确定进行块操作的块大小siz = bestblk(m n,k)mb,nb = bestblk(m n,k)blkproc实现图像的非重叠(distinct)块操作B = blkproc(A,m n,fun)B = blkproc(A,m n,fun,P1,P2,.)B=blkproc(A,m n,mborder nbord

27、er, fun, .)B = blkproc(A,indexed,.)col2im 将矩阵的列重新组织到块中A = col2im(B,m n,mm nn, block_type)A = col2im(B,m n,mm nn)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,.)im2col 重调图像块为列B =

28、 im2col(A,m n,block_type)B = im2col(A,m n)B = im2col(A,indexed,.)nlfilter 通用滑动邻域操作B = nlfilter(A,m n,fun)B = nlfilter(A,m n,fun,P1,P2,.)B = nlfilter(A,indexed,.)表 11 图像形态学操作函数函数 功能 语法applylut在二值图像中利用查找表进行邻域操作A = applylut(BW,LUT)bwarea 计算二值图像的对象面积 total = bwarea(BW)MATLAB 图像处理工具箱函数第 10 页 共 14 页bweule

29、r 计算二值图像的欧拉数 eul = bweuler(BW,n)bwhitmiss执行二值图像的击中和击不中操作BW2 = bwhitmiss(BW1,SE1,SE2)BW2 = bwhitmiss(BW1,INTERVAL)bwlabel标注二值图像中已连接的部分L = bwlabel(BW,n)L,num = bwlabel(BW,n)bwmorph 二值图像的通用形态学操作BW2 = bwmorph(BW,operation)BW2 = bwmorph(BW,operation,n)bwperim 计算二值图像中对象的周长BW2 = bwperim(BW1)BW2 = bwperim(B

30、W1,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,P1,P2,.)bwdist 距离变换D = bwdist(BW)D,L = bwdist(BW)D,L = bwdist(BW,METHOD)imbothat

31、 执行形态学的闭包运算IM2 = imbothat(IM,SE)IM2 = imbothat(IM,NHOOD)imclose 图像的闭运算IM2 = imclose(IM,SE)IM2 = imclose(IM,NHOOD)imopen 图像的开运算IM2 = imopen(IM,SE)IM2 = imopen(IM,NHOOD)imdilate 图像的膨胀IM2 = imdilate(IM,SE)IM2 = imdilate(IM,NHOOD)IM2 = imdilate(IM,SE,PACKOPT)IM2 = imdilate(.,PADOPT)imerode 图像的腐蚀IM2 = im

32、erode(IM,SE)IM2 = imerode(IM,NHOOD)IM2 = imerode(IM,SE,PACKOPT,M)IM2 = imerode(.,PADOPT)imfill 填充图像区域BW2 = imfill(BW,locations)BW2 = imfill(BW,holes)I2 = imfill(I)BW2 = imfill(BW)BW2 locations = imfill(BW)MATLAB 图像处理工具箱函数第 11 页 共 14 页BW2 = imfill(BW,locations,CONN)BW2 = imfill(BW,CONN,holes)I2 = imf

33、ill(I,CONN)imtophat用开运算后的图像减去原图像IM2 = imtophat(IM,SE)IM2 = imtophat(IM,NHOOD)strel 创建形态学结构元素 SE = strel(shape,parameters)表 12 区域处理函数函数 功能 语法roicolor 选择感兴趣的颜色区BW = roicolor(A,low,high)BW = roicolor(A,v)roifill在图像的任意区域中进行平滑插补J = roifill(I,c,r)J = roifill(I)J = roifill(I,BW)J,BW = roifill(.)J = roifill

34、(x,y,I,xi,yi)x,y,J,BW,xi,yi = roifill(.)roifilt2 滤波特定区域J = roifilt2(h,I,BW)J = roifilt2(I,BW,fun)J = roifilt2(I,BW,fun,P1,P2,.)roipoly选择一个感兴趣的多边形区域BW = roipoly(I,c,r)BW = roipoly(I)BW = roipoly(x,y,I,xi,yi)BW,xi,yi = roipoly(.)x,y,BW,xi,yi = roipoly(.)表 13 图像代数操作函数 功能 语法imadd 加运算 Z = imadd(X,Y)imsub

35、tract 减运算 Z = imsubtract(X,Y)immultiply 乘运算 Z = immultiply(X,Y)imdivide 除运算 Z = imdivide(X,Y)表 14 颜色空间转换函数函数 功能 语法hsv2rgb转换 HSV 的值为 RGB 颜色空间M = hsv2rgb(H)ntsc2rgb转换 NTSC 的值为 RGB 颜色空间rgbmap = ntsc2rgb(yiqmap)RGB = ntsc2rgb(YIQ)MATLAB 图像处理工具箱函数第 12 页 共 14 页rgb2hsv转换 RGB 的值为 HSV 颜色空间cmap = rgb2hsv(M)rg

36、b2ntsc转换 RGB 的值为 NTSC 颜色空间yiqmap = rgb2ntsc(rgbmap)YIQ = rgb2ntsc(RGB)rgb2ycbcr转换 RGB 的值为 YCbCr 颜色空间ycbcrmap = rgb2ycbcr(rgbmap)YCBCR = rgb2ycbcr(RGB)ycbcr2rgb转换 YCbCr 的值为 RGB 颜色空间rgbmap = ycbcr2rgb(ycbcrmap)RGB = ycbcr2rgb(YCBCR)表 15 图像类型和类型转换函数函数 功能 语法dither通过抖动增加外观颜色分辨率,转换图像X = dither(RGB,map)BW

37、= dither(I)gray2ind 转换灰度图像为索引色图像X,map = gray2ind(I,n)X,map = gray2ind(BW,n)grayslice 从灰度图像为索引色图像X = grayslice(I,n)X = grayslice(I,v)im2bw 转换图像为二值图像BW = im2bw(I,level)BW = im2bw(X,map,level)BW = im2bw(RGB,level)im2double 转换图像矩阵为双精度类型I2 = im2double(I)RGB2 = im2double(RGB)I = im2double(BW)X2 = im2doubl

38、e(X,indexed)double 转换数据为双精度类型 double(X)uint8 转换数据为 8 位无符号整型 I = uint8(X)im2uint8转换图像阵列为 8 位为无符号整型I2 = im2uint8(I)RGB2 = im2uint8(RGB)I = im2uint8(BW)X2 = im2uint8(X,indexed)im2uint16转换图像阵列为 16 位为无符号整型I2 = im2uint16(I)RGB2 = im2uint16(RGB)I = im2uint16(BW)X2 = im2uint16(X,indexed)uint16转换数据为 16 位无符号整

39、型I = uint16(X)ind2gray 转换索引色图像为灰度图像 I = ind2gray(X,map)ind2rgb 转换索引色图像为 RGB 图 RGB = ind2rgb(X,map)MATLAB 图像处理工具箱函数第 13 页 共 14 页像isbw 判断是否为二值图像 flag = isbw(A)isgray 判断是否为灰度图像 flag = isgray(A)isind 判断是否为索引色图像 flag = isind(A)isrgb 判断是否为 RGB 图像 flag = isrgb(A)mat2gray 转换矩阵为灰度图像I = mat2gray(A,amin amax)I

40、 = mat2gray(A)rgb2gray转换 RGB 图像或颜色映射表为灰度图像I = rgb2gray(RGB)newmap = rgb2gray(map)rgb2ind转换 RGB 图像为索引色图像X,map = rgb2ind(RGB,tol)X,map = rgb2ind(RGB,n)X = rgb2ind(RGB,map). = rgb2ind(.,dither_option)表 16 图像复原函数函数 功能 语法deconvwnr 用维纳滤波复原图像J = deconvwnr(I,PSF)J = deconvwnr(I,PSF,NSR)J = deconvwnr(I,PSF,N

41、CORR,ICORR)deconvreg用最小约束二乘滤波复原图像J = deconvreg(I,PSF)J = deconvreg(I,PSF,NOISEPOWER)J = deconvreg(I, PSF, NOISEPOWER, LRANGE )J = deconvreg(I, PSF, NOISEPOWER, LRANGE, REGOP)J, LAGRA = deconvreg(I,PSF,.)deconvlucy用 Richardson-Lucy 滤波复原图像J = deconvlucy(I,PSF)J = deconvlucy(I,PSF,NUMIT)J = deconvlucy(

42、I,PSF,NUMIT,DAMPAR)J = deconvlucy(I, PSF, NUMIT, DAMPAR, WEIGHT)J = deconvlucy(I, PSF, NUMIT, DAMPAR, WEIGHT, READOUT)J = deconvlucy(I, PSF, NUMIT, DAMPAR, WEIGHT, READOUT, SUBSMPL)deconvblind 用盲卷积滤波复原图像J,PSF = deconvblind(I,INITPSF)J,PSF = deconvblind(I,INITPSF,NUMIT)J,PSF = deconvblind(I, INITPSF, NUMIT, MATLAB 图像处理工具箱函数第 14 页 共 14 页DAMPAR)J,PSF = deconvblind(I, INITPSF, NUMIT, DAMPAR, WEIGHT)J,PSF = deconvblind(I, INITPSF, NUMIT, DAMPAR, WEIGHT, READOUT )J,PSF = deconvblind(., FUN, P1, P2, ., PN)

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报