2013-11-03 227 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 (@)