-3

I have not understood the code and the way function is handled..

can you elaborate the function declaration

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

Also in susan corner detector we have only 2 threshold values.. "t and g".. but here we have "thGeo,thGeo1,thGeo2,thT,thT1"

I am not able to understand the method employed here:

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
John
  • 1
  • 1
  • 3
    Since all the code here is just copied from http://www.mathworks.com.au/matlabcentral/fileexchange/30789-corner-detection-using-susan-operator/content/susanCorner.m, wouldn't it be best to just ask the author (whose address you can find via that page). – Bull Nov 03 '13 at 13:47

1 Answers1

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

means

  • fun is a handle (or pointer) to a function.
  • @(img) says fun takes an argument called img.
  • susanFun(img) is the body of fun

nlfilter is passed the function handle fun and can call it. In fact, it will apply fun with the parameter img as each 7x7 sliding block of the image img. Note that the name img is overloaded here: it is name name of a variable holding an image, and it is the name of the parameter of fun.

See function_handle (@)

Bull
  • 11,771
  • 9
  • 42
  • 53