edge()
2008-03-21 16:27:06
看到了edge()函数的代码,比我想的好像复杂了很多,尤其在处理canny算子的时候还是蛮复杂的。其他的大概思路还是明确的。
%EDGE Find edges in intensity image.LUPA开源社区tf&Hkq?|8~i
% EDGE takes an intensity or a binary image I as its input, and returns a
_AR.sH3q2M1^0% binary image BW of the same size as I, with 1's where the function LUPA开源社区b
JC[N;ZM$?z
% finds edges in I and 0's elsewhere.LUPA开源社区&sB7H{0^v(z-d3ZT
%LUPA开源社区&X.k$x8IW;K-Y
% EDGE supports six different edge-finding methods:
V7J GT,_"e*U0%
+P%A2x+{$N5K0% The Sobel method finds edges using the Sobel approximation to the
}:A&S4Wy;vF8Y0M0% derivative. It returns edges at those points where the gradient ofLUPA开源社区&`$i4]+v!s
% I is maximum.
!~r0\7C%@!aX0%
%P'P@-I.ftsx$a0% The Prewitt method finds edges using the Prewitt approximation to
9vNS"xKC0% the derivative. It returns edges at those points where the gradient
V:zAsA;C,`a6G_V0% of I is maximum.
n:{zw1D^G0%
go@IVV)F9J;Ml.q0% The Roberts method finds edges using the Roberts approximation to
Cw2T{ y Y(L0% the derivative. It returns edges at those points where the gradient
fF#{[`2R"H,E0% of I is maximum.
U9k7f4?'Mp$yr0%LUPA开源社区U(`-y\vMr2@n
% The Laplacian of Gaussian method finds edges by looking for zeroLUPA开源社区r3P7zY2c
H
% crossings after filtering I with a Laplacian of Gaussian filter.LUPA开源社区;[KY#g5y
j7KP
%LUPA开源社区},byn1@0{
% The zero-cross method finds edges by looking for zero crossingsLUPA开源社区2^
F:k!]9Ee'o
% after filtering I with a filter you specify.
0wh | p'ya3{BI9i \0%
"\F't ?R{Gt0% The Canny method finds edges by looking for local maxima of the
ym$o#WtF p0% gradient of I. The gradient is calculated using the derivative of aLUPA开源社区I7\yO,~
% Gaussian filter. The method uses two thresholds, to detect strongLUPA开源社区,i-`3k8pE:IK
% and weak edges, and includes the weak edges in the output only ifLUPA开源社区s%s*u7U,W5P0Z
% they are connected to strong edges. This method is therefore lessLUPA开源社区B%p:k@~&[7dG{V
% likely than the others to be "fooled" by noise, and more likely to
%A7RW.V/?1Kig[
L0% detect true weak edges.
5B:lg#q(p8e&n0%LUPA开源社区-@%W6e/j eXD
% The parameters you can supply differ depending on the method you
*y2W;g"xK0% specify. If you do not specify a method, EDGE uses the Sobel method.
最后图像的输出也是有一个阈值化处理的过程
% determine the threshold; see page 514 of "Digital Imaging Processing" by
`k3xW;dc:z1v0 % William K. Pratt
L!j.D8GI(x2R0 if isempty(thresh), % Determine cutoff based on RMS estimate of noiseLUPA开源社区#_#sE)qkjPH]
% Mean of the magnitude squared image is a
z8}B"M ?7|0 % value that's roughly proportional to SNRLUPA开源社区 _`V&g
^w0M{(v
g&?"|
cutoff = scale*mean2(b);
"A!M_:mM'U0 thresh = sqrt(cutoff);LUPA开源社区j oF
T;SU&]
else % Use relative tolerance specified by the user
7i3j
Q'A\a
L9v0 cutoff = (thresh).^2;
ys;T1~kW
L6k0 end
J@:n~$|g
w0
ZyH,kN-VC `'Q0 if thinning
x e"~1z8tjn
R0 bx = abs(bx); % necessary for doing local maxima suppression
#z}3d!Q?3v0 by = abs(by);
1T-r.N P#D0 end
推荐 收藏 导入论坛 等级(1) 编辑 管理 查看(7) 评论(0) 评分(0/0)
TAG: