zoukankan      html  css  js  c++  java
  • 边缘检测matlab算法汇总

    边缘检测matlab算法汇总

    1.      基于一阶微分算子检测边缘图像

    一阶微分边缘算子又称梯度边缘算子,它是利用图像在边缘处的阶跃性,及图像梯度在边缘去得极大值得特征性进行边缘检测。

    Sobel算子:image =edge(in_image,’sobel’,threshold,direction);

    Prewitt算子: image = edge(in_image,’prewitt’,threshold,direction);

    Roberts算子: image = edge(in_image,’sobel’,threshold);

    其中,in_image 是灰度图像,threshold是阈值,direction是方向。

    优点:实现简单、运算速度快

    缺点:易受噪音影响,主要原因其一是实际边缘灰度与理想边缘灰度存在差异,有可能检测出多个边缘;其二是算子尺度固定不利于检测出不同尺度的边缘。

    Canny算子:image = edge(in_image,’canny’,threshold);

    其中,in_image 是灰度图像,threshold是阈值。

             canny算子主要在原一阶微分算子基础上进行了扩展,增加了非最大值抑制和双阈值两项改进。利用非最大值抑制不仅可以有效地抑制多响应边缘,而且还可以提高边缘的定位精度。利用双阈值可以有效减少边缘的漏检率。主要分为4步进行:高斯平滑去噪、计算梯度与方向角、非最大值抑制、滞后阈值化。 

    2.      基于二阶微分算子检测边缘图像

    二阶微分边缘检测算子是利用图像在边缘处的阶跃性导致图像二阶微分在边缘处出现零值这一特性进行边缘检测的,因此该算法又称零点算子和拉普拉斯算子。

    高斯拉普拉斯方法(laplacian of Gaussian, LoG):image = edge(in_image,’log’,threshold);

    其中,in_image 是灰度图像,threshold是阈值。

    Log算子检测边缘的结果要由于roberts和sobel算子,检测出来的边缘比较完整,且抗噪能力较好。

     

    3.      基于SUSAN特征检测算子的边缘提取

    SUSAN(Smallest Univalue Segment AssimilatingNucleus),又称最小核值相似区。它使用一个原型模板和一个圆的中心点,通过圆心点像元值与模板圆内其他像元值的比较,统计出圆中心点像元值近似的像元数量,并与所设定的阈值进行比较,以确定是否是边缘。

    [plain] view plain copy
    1. function image_out = susan(im,threshold)  
    2. % 功能:实现运用SUNSAN算子进行边缘检测  
    3. % 输入:image_in-输入的待检测的图像  
    4. %       threshold-阈值  
    5. % 输出:image_out-检测边缘出的二值图像  
    6.   
    7. % 将输入的图像矩阵转换成double型  
    8. d = length(size(im));  
    9. if d==3  
    10.     image=double(rgb2gray(im));  
    11. elseif d==2  
    12.     image=double(im);  
    13. end  
    14.    
    15. % 建立SUSAN模板  
    16.    
    17. mask = ([ 0 0 1 1 1 0 0 ;0 1 1 1 1 1 0;1 1 1 1 1 1 1;1 1 1 1 1 1 1;1 1 1 1 1 1 1;0 1 1 1 1 1 0;0 0 1 1 1 0 0]);    
    18.    
    19. R=zeros(size(image));  
    20. % 定义USAN 区域  
    21. nmax = 3*37/4;  
    22.   
    23.  [a b]=size(image);  
    24. new=zeros(a+7,b+7);  
    25. [c d]=size(new);  
    26. new(4:c-4,4:d-4)=image;  
    27.     
    28. for i=4:c-4  
    29.       
    30.     for j=4:d-4  
    31.           
    32.         current_image = new(i-3:i+3,j-3:j+3);  
    33.         current_masked_image = mask.*current_image;  
    34.      
    35. %   调用susan_threshold函数进行阈值比较处理  
    36.                   
    37.         current_thresholded = susan_threshold(current_masked_image,threshold);  
    38.         g=sum(current_thresholded(:));  
    39.           
    40.         if nmax<g  
    41.             R(i,j) = g-nmax;  
    42.         else  
    43.             R(i,j) = 0;  
    44.         end  
    45.     end  
    46. end  
    47.    
    48. image_out=R(4:c-4,4:d-4);  
    [plain] view plain copy
    1.   
    [plain] view plain copy
    1. susan_threshold函数  
    [html] view plain copy
    1. function thresholded = susan_threshold(image,threshold)  
    2. % 功能:设定SUSAN算法的阈值  
    3.   
    4. [a b]=size(image);  
    5. intensity_center = image((a+1)/2,(b+1)/2);  
    6.    
    7. temp1 = (image-intensity_center)/threshold;  
    8. temp2 = temp1.^6;  
    9. thresholded = exp(-1*temp2);  

    优点:抗噪能力好、计算量小速度快、可以检测边缘的方向信息。





  • 相关阅读:
    Codeforces 220C
    Codeforces 697D
    HDU 4417
    Codeforces 396C
    Codeforces 246C
    HDU 6333
    HDU 3389
    总结:树上启发式合并
    HDU 6319
    Codeforces 1009G
  • 原文地址:https://www.cnblogs.com/jins-note/p/9520199.html
Copyright © 2011-2022 走看看