Image Processing Reference
In-Depth Information
Fig. 6.3 The three levels of
operation involved in
Morphology
6.1.1 Hit
For each '1' in the structuring element we investigate whether the pixel at the same
position in the image is also a '1'. If this is the case for just one of the '1's in the
structuring element we say that the structuring element hits the image at the pixel
position in question (the one on which the structuring element is centered). This
pixel is therefore set to '1' in the output image. Otherwise it is set to '0'. In Fig. 6.4
and Table 6.1 the hit operation is illustrated with two different structuring elements.
6.1.2 Fit
For each '1' in the structuring element we investigate whether the pixel at the same
position in the image is also a '1'. If this is the case for all the '1's in the structuring
element we say that the structuring element fits the image at the pixel position in
question (the one on which the structuring element is centered). This pixel is there-
fore set to '1' in the output image. Otherwise it is set to '0'. In Fig. 6.4 and Table 6.1
the fit operation is illustrated with two different structuring elements. Below we
show C-code for the fit operation using a 3
×
3 box-shaped structuring element:
Temp
=
0 ;
for
(j = y
1;
j
<
( y + 2 ) ;
j
=
j +1)
{
for
(i = x
1;
i <
( x + 2 ) ;
i
=
i +1)
{
if
( GetPixel ( input ,
i ,
j )
==
1)
Temp
=
Temp
+
1 ;
}
}
if (Temp == 9)
SetPixel ( output ,
x,
y,
1);
else
SetPixel ( output ,
x,
y,
0);
where (x, y) is the position of the pixel being processed.
Search WWH ::




Custom Search