Image Processing Reference
In-Depth Information
Averaging also gives some immunity to noise and it can be replaced by a weighted average
if Gaussian smoothing is required. The number of pixels considered, the value of n , defines
a compromise between accuracy and noise sensitivity. Notice that filtering techniques may
also be used to reduce the quantisation effect when angles are obtained by an edge detection
operator. As we have already discussed, the level of filtering is related to the size of the
template (as in Section 3.4.3).
In order to compute angular differences, we need to determine connected edges. This
can easily be implemented with the code already developed for hysteresis thresholding in
the Canny edge operator. To compute the difference of points in a curve, the connect
routine (Code 4.12 ) only needs to be arranged to store the difference in edge direction
between connected points. Code 4.16 shows an implementation for curvature detection.
First, edges and magnitudes are determined. Curvature is only detected at edge points. As
such, we apply maximal suppression. The function Cont returns a matrix containing the
connected neighbour pixels of each edge. Each edge pixel is connected to one or two
neighbours. The matrix Next stores only the direction of consecutive pixels in an edge.
We use a value of -1 to indicate that there is no connected neighbour. The function
NextPixel obtains the position of a neighbouring pixel by taking the position of a pixel
and the direction of its neighbour. The curvature is computed as the difference in gradient
direction of connected neighbour pixels.
%Curvature detection
function outputimage=Curve Connect (inputimage)
[rows, columns]=size(inputimage);
%Image size
outputimage=zeros(rows,columns);
%Result image
[Mag, Ang]=Edges(inputimage);
%Edge Detection
Mag=MaxSupr(Mag,Ang);
Magnitude and Angle
Next=Cont(Mag,Ang);
%Maximal Suppression
%Next connected pixels
%Compute curvature in each pixel
for x=1: columns-1
for y=1: rows-1
if Mag(y,x)~=0
n=Next(y,x,1); m=Next(y,x,2);
if(n~=-1 & m~=-1)
[px,py]=NextPixel(x,y,n);
[qx,qy]=NextPixel(x,y,m);
outputimage(y, x)=abs(Ang(py, px)-Ang(qy, qx));
end
end
end
end
Code 4.16
Curvature by differences
The result of applying this form of curvature detection to an image is shown in Figure
4.32 . Here Figure 4.32 (a) contains the silhouette of an object; Figure 4.32 (b) is the curvature
Search WWH ::




Custom Search