Susan Corner Detector实施 [英] Susan Corner Detector implementation
问题描述
我还没有理解代码和函数的处理方式..
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);
同样在苏珊角落检测器中,我们只有2个阈值..t和g..但是这里我们有thGeo,thGeo1,thGeo2,thT,thT1
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
推荐答案
fun = @(img) susanFun(img);
map = nlfilter(img,maskSz,fun);
表示
-
fun
是函数的句柄(或指针)。 -
@(img)
说fun
接受一个名为img
的参数。 -
susanFun(img)
是的主体乐趣
fun
is a handle (or pointer) to a function.@(img)
saysfun
takes an argument calledimg
.susanFun(img)
is the body offun
nlfilter
传递函数句柄 fun
并可以调用它。
实际上,它会将 fun
与参数 img
一起应用为图像的每个7x7滑动块 IMG
。
请注意,名称 img
在这里重载:它是包含图像的变量的名称,它是<$ c $参数的名称c>有趣。
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
.
这篇关于Susan Corner Detector实施的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!