2013-11-03 349 views
-3

我不明白的代码和功能的方式进行处理..苏珊角检测实施

可以为您详细的函数声明

fun = @(img) susanFun(img); 
map = nlfilter(img,maskSz,fun); 

我们只有2的阈值也苏珊角点检测。 “T和G” ..但在这里我们有 “thGeo,thGeo1,thGeo2,THT,thT1”

我无法理解这里所采用的方法:

function [ map r c ] = susanCorner(img) 
%SUSAN Corner detection using SUSAN method. 
% [R C] = SUSAN(IMG) Rows and columns of corner points are returned. 


maskSz = [7 7]; 
fun = @(img) susanFun(img); 
map = nlfilter(img,maskSz,fun); 
[r c] = find(map); 

end 

function res = susanFun(img) 
% SUSANFUN Determine if the center of the image patch IMG 
% is corner(res = 1) or not(res = 0) 


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]; 

% uses 2 thresholds to distinguish corners from edges 
thGeo = (nnz(mask)-1)*.2; 
thGeo1 = (nnz(mask)-1)*.4; 
thGeo2 = (nnz(mask)-1)*.4; 
thT = .07; 
thT1 = .04; 

sz = size(img,1); 
usan = ones(sz)*img(round(sz/2),round(sz/2)); 

similar = (abs(usan-img)<thT); 
similar = similar.*mask; 
res = sum(similar(:)); 
if res < thGeo 
    dark = nnz((img-usan<-thT1).*mask); 
    bright = nnz((img-usan>thT1).*mask); 
    res = min(dark,bright)<thGeo1 && max(dark,bright)>thGeo2; 

else 
    res = 0; 
end 

end 
+3

因为这里所有的代码是刚刚从http://www.mathworks.com.au/matlabcentral/fileexchange/30789-corner-detection-using-susan-operator/content/susanCorner复制。米,是不是最好问问作者(你可以通过该页面找到他的地址)。 – Bull

回答

0
fun = @(img) susanFun(img); 
map = nlfilter(img,maskSz,fun); 

装置

  • fun是手柄(或指针)的功能。
  • @(img)fun需要一个名为img的参数。
  • susanFun(img)fun

nlfilter身体传递函数处理fun并且可以调用它。 实际上,它将应用fun与参数img作为图像img的每个7x7滑动块。 请注意,名称img在此处被重载:它是一个保存图像的变量的名称名称,它是参数名称fun

function_handle (@)