Image Processing Reference
In-Depth Information
SS
-
S S
SS
-
-
SS
xt
4
2
3
2
2
3
xt
t
xt
t
t
t
t
b
=
c
=
x
x
2
2
SS
-
S
SS
S
24
24
3
3
t
t
t
t
t
t
(4.46)
SS
-
S S
SS
-
SS
yt
4
2
3
2
2
3
yt
t
yt
t
t
t
t
b
=
c
=
y
y
2
2
SS
-
S
SSS
-
S
24
24
3
3
t
t
t
t
t
t
Code 4.17 shows the implementation of Equation 4.41. First, we obtain the edges and the
matrix Next that stores the direction of the connected pixels. For each edge pixel, we
compute the leading and trailing curve segments. These segments are stored in the vectors
Lchain and Rchain. These segments are obtained by following the curve until it goes
out of a predefined square region. Then, we use Equations 4.44 and 4.45 to obtain the mean
square fit. Finally, based on the fitted curve we compute the curvature. Figure 4.33 shows
the result of the curvature obtained by this approach. Here we use a window 7 pixels wide.
%Curvature via fitting
function outputimage=CurvFit(inputimage)
w=3; %Parameter window size=2w+1
[rows, columns]=size(inputimage); %Image size
outputimage=zeros(rows,columns);
%Result image
[Mag,Ang]=Edges(inputimage);
%Edge Detection
Mag=MaxSuper(Mag,Ang);
%Maximal Suppression
Next=Cont(Mag,Ang);
%Next connected pixels
%compute curvature for pixel (x,y)
for x=w+1:columns-w
for y=w+1:rows-w
%compute leading curve segment
i=0;n=Next(y,x,1); p=[x,y];
Lchain=[];
while i<w & n~=-1
i=i+1;
[qx,qy]=NextPixel(p(1),p(2),n);
p=[qx,qy];
Lchain=[Lchain;p];
m=rem(n+4,8);
if(Next(p(2),p(1),1)~=-1 & Next(p(2), p(1),1)~=m)
n=Next(p(2),p(1),1);
elseif Next(p(2),p(1),2)~=m
n=Next(p(2),p(1),2);
else
n=-1;
end
end
%compute trailing curve segment
i=0; n=Next(y,x,2); p=[x,y];
Rchain=[];
Search WWH ::




Custom Search