SUSAN,Smallest Univalue Segment Assimilatating Nucleus的缩写,即最小核值相似区,是由牛津大学的Smith等提出来的。SUSAN算子是一种高效的边缘和角点检测算子,并且具有结构保留的降噪功能(structure preserving noise reduction )。SUSAN使用一个圆形模板和一个圆的中心点,通过圆中心像元值与模板圆内其他像元值得比较,统计出与圆中心点像元值近似的像元数量,当这样的像元值数量小于一个阈值,就被认为是要检测的角点。
SUSAN角点检测过程如下:
(1)对于图像中的每个像元,将核放在该像元上;
(2)利用下式计算模板圆内像元与核像元相似的像元数量,该像元数量即为USAN;
(3)使用下式计算角点的相应值;
(4)使用非最大值抑制,找出角点集。
clear all;close all;clc; img=imread('7.jpg'); img=rgb2gray(img); imshow(img); [m n]=size(img); img=double(img); t=45; %模板中心像素与周围灰度差别的阈值,自己设置 usan=[]; %当前像素与周围在像素差别在t以下的个数 for i=4:m-3 %没有在外围扩展图像,最终图像会缩小 for j=4:n-3 tmp=img(i-3:i+3,j-3:j+3); %7*7模板 c=0; for p=1:7 for q=1:7 if (p-4)^2+(q-4)^2<=12 %在其中筛选,最终模板类似一个圆形 if abs(img(i,j)-tmp(p,q))<t %判断灰度是否相近,t是自己设置的 c=c+1; end end end end usan=[usan c]; end end g=2*max(usan)/3; %确定角点提取的数量,值比较高时会提取出边缘,自己设置 for i=1:length(usan) if usan(i)<g usan(i)=g-usan(i); else usan(i)=0; end end imgn=reshape(usan,[n-6,m-6])'; % '转置 figure; imshow(imgn); %非极大抑制 [m n]=size(imgn); re=zeros(m,n); for i=2:m-1 for j=2:n-1 if imgn(i,j)>max([max(imgn(i-1,j-1:j+1)) imgn(i,j-1) imgn(i,j+1) max(imgn(i+1,j-1:j+1))]); re(i,j)=1; else re(i,j)=0; end end end imshow(re==1);
image_in=imread('01.jpg'); image = susan(image_in,27); imshow(image,[])
close all clc % check to see if the image is a color image... d = length(size(im)); if d==3 image=double(rgb2gray(im)); elseif d==2 image=double(im); end % mask for selecting the pixels within the circular region (37 pixels, as % used in the SUSAN algorithm 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]); % the output image indicating found edges R=zeros(size(image)); % define the USAN area nmax = 3*37/4; % padding the image [a b]=size(image); new=zeros(a+7,b+7); [c d]=size(new); new(4:c-4,4:d-4)=image; for i=4:c-4 for j=4:d-4 current_image = new(i-3:i+3,j-3:j+3); current_masked_image = mask.*current_image; % Uncomment here to implement binary thresholding % current_masked_image(find(abs(current_masked_image-current_masked_image(4,4))>threshold))=0; % current_masked_image(find(abs(current_masked_image-current_masked_image(4,4))<=threshold))=1; % This thresholding is more stable current_thresholded = susan_threshold(current_masked_image,threshold); g=sum(current_thresholded(:)); if nmax<g R(i,j) = g-nmax; else R(i,j) = 0; end end end image_out=R(4:c-4,4:d-4);
[a b]=size(image); intensity_center = image((a+1)/2,(b+1)/2); temp1 = (image-intensity_center)/threshold; temp2 = temp1.^6; thresholded = exp(-1*temp2);