Matlab图像处理函数汇总

来源:互联网 发布:淘宝恶意退款会坐牢吗 编辑:程序博客网 时间:2024/04/16 19:17

                 Matlab图像处理函数汇总

1.图像的变换:

   ① fft2:fft2函数用于数字图像的二维傅立叶变换,如:
     i=imread('104_8.tif');     j=fft2(i);</span>

   ② ifft2: ifft2函数用于数字图像的二维傅立叶反变换,如:

     i=imread('104_8.tif');     j=fft2(i);     k=ifft2(j);</span>

2.模拟噪声生成函数和预定义滤波器:

   ① imnoise:用于对图像生成模拟噪声,如:

     i=imread('104_8.tif');     j=imnoise(i,'gaussian',0,0.02); %模拟高斯噪声</span>

   ② fspecial:用于产生预定义滤波器,如:

     h=fspecial('sobel');     %sobel水平边缘增强滤波器     h=fspecial('gaussian');   %高斯低通滤波器     h=fspecial('laplacian');   %拉普拉斯滤波器     h=fspecial('log');         %高斯拉普拉斯(LoG)滤波器     h=fspecial('average');     %均值滤波器</span>

3.图像的增强:

   ①直方图:imhist函数用于数字图像的直方图显示,如:

    i=imread('104_8.tif');    imhist(i);</span>

   ②直方图均化:histeq函数用于数字图像的直方图均化,如:

     i=imread('104_8.tif');     j=histeq(i);</span>

   ③对比度调整:imadjust函数用于数字图像的对比度调整,如:

          i=imread('104_8.tif');          j=imadjust(i,[0.3,0.7],[]);</span></span>

   ④对数变换:log函数用于数字图像的对数变换,如:

     i=imread('104_8.tif');     j=double(i);     k=log(j);</span>

   ⑤基于卷积的图像滤波函数:filter2函数用于图像滤波,如:

     i=imread('104_8.tif');     h=[1,2,1;0,0,0;-1,-2,-1];     j=filter2(h,i);</span>

   ⑥线性滤波:利用二维卷积conv2滤波, 如:

      i=imread('104_8.tif');      h=[1,1,1;1,1,1;1,1,1];      h=h/9;      j=conv2(i,h);</span>
   ⑦中值滤波:medfilt2函数用于图像的中值滤波,如:

     i=imread('104_8.tif');     j=medfilt2(i);</span>

   ⑧锐化

   (1)利用Sobel算子锐化图像, 如:

    i=imread('104_8.tif');    h=[1,2,1;0,0,0;-1,-2,-1];   %Sobel算子    j=filter2(h,i);</span>
   (2)利用拉氏算子锐化图像, 如:

    i=imread('104_8.tif');    j=double(i);    h=[0,1,0;1,-4,0;0,1,0];  %拉氏算子    k=conv2(j,h,'same');    m=j-k;</span>

4.图像边缘检测:

   ① sobel算子 如:

    i = imread('104_8.tif');    j = edge(i,'sobel',thresh);</span>
   ② prewitt算子 如:

    i = imread('104_8.tif');    j = edge(i,'prewitt',thresh);</span>
   ③roberts算子  如:

    i=imread('104_8.tif');    j =edge(i,'roberts',thresh);</span>

   ④log算子  如:

   i=imread('104_8.tif');    j =edge(i,'log',thresh);</span>

   ⑤canny算子 如:

    i=imread('104_8.tif');    j =edge(i,'canny',thresh);</span>

   ⑥Zero-Cross算子 如:

    i=imread('104_8.tif');    j =edge(i,'zerocross',thresh);</span>

5.形态学图像处理:

   ①膨胀:是在二值化图像中“加长”或“变粗”的操作,函数imdilate执行膨胀运算,如:

    a=imread('104_7.tif');  %输入二值图像    b=[0 1 0;1 1 1;01 0];    c=imdilate(a,b);</span>
     ②腐蚀:函数imerode执行腐蚀,如:

    a=imread('104_7.tif');   %输入二值图像    b=strel('disk',1);    c=imerode(a,b);</span>

   ③开运算:先腐蚀后膨胀称为开运算,用imopen来实现,如:

   a=imread('104_8.tif');   b=strel('square',2);   c=imopen(a,b);</span>

   ④闭运算:先膨胀后腐蚀称为闭运算,用imclose来实现,如:

   a=imread('104_8.tif');    b=strel('square',2);    c=imclose(a,b);</span>

6.改变MATLAB背景颜色:

% 不使用MATLAB首选项中的配色com.mathworks.services.Prefs.setBooleanPref('ColorsUseSystem',0);% 指定背景颜色com.mathworks.services.Prefs.setColorPref('ColorsBackground',java.awt.Color.green);com.mathworks.services.ColorPrefs.notifyColorListeners('ColorsBackground');cmdWinDoc = com.mathworks.mde.cmdwin.CmdWinDocument.getInstance;listeners = cmdWinDoc.getDocumentListeners;ii=1;% 循环的方式,找到jTextArea的实例,然后设置颜色while true    jTextArea = listeners(ii);    if isa(jTextArea,'javax.swing.JTextArea$AccessibleJTextArea')        break    end    ii=ii+1;end% 可以使用下面任意一种方法设置背景色jTextArea.setBackground(java.awt.Color.green);jTextArea.setBackground(java.awt.Color(0,1,0));set(jTextArea,'Background','green');set(jTextArea,'Background',[0,1,0]);</span>

7.小波变换:

   ① 使用小波工具箱:

    wfilters:得到分解滤波器;

    wavedec2:分解等级函数,得到变换系数;

    waverec2:得到重构滤波器。

   ② 不使用小波工具箱:

    wavefiler:代替wfilters;

    wavefast:代替wavedec2;

    wavework:处理C(有三个使用wavework功能类似函数:wavecut,wavecopy,wavepaste);

    wave2gray:显示变换系数;

    waveback:代替waverec2。



0 0
原创粉丝点击