Page 139 -
P. 139
Chapter 3 ■ Digital Morphology 113
command prompt. The compiler now asks for the source file name from an
input prompt:
MAX
MAX compiler: enter source code file name (ends in .max): t1.max
This will compile the program t1.max into C code file called t1.c.On most
systems this will be automatically compiled into the object file t1.exe and
then executed. In order for the C compilation to be successful, the files max.h
and maxlib.c must be in the same working directory.
As a tool for education and as a test bed for morphological experimentation
and testing of structuring elements, MAX is still unique (if perhaps not perfect).
For example, the program BinDil can now be written:
// Dilation using ++
image a, b;
begin
do (a << ˝ $1˝)++(b<< ˝ $2˝) >> ˝ $3˝
end;
Figure 3.17 shows a MAX program for doing a dilation the hard way: by
translating the structuring element to all pixel positions in the image being
dilated and accumulating the union of all these images (sets). From this
point forward, programs illustrating morphological operations will be written
in MAX.
3.3.7 The ‘‘Hit-and-Miss’’ Transform
The hit-and-miss transform is a morphological operator designed to locate
simple shapes within an image. It is based on erosion; this is natural, because
the erosion of A by S consists only of those pixels (locations) where S is
contained within A, or matches the set pixels in a small region of A. However,
it also includes places where the background pixels in that region do not
match those of S, and these locations would not normally be thought of as a
match. What we need is an operation that matches both the foreground and
the background pixels of S in A.
Matching the foreground pixels in S against those in A is a ‘‘hit’’, and is
accomplished with a simple erosion A S. The background pixels in A are
c
c
those found in A , and while we could use S as the background for S a
more flexible approach is to specify the background pixels explicitly in a new
structuring element T. A ‘‘hit’’ in the background is called a ‘‘miss,’’ and is
c
found by A T. We want the locations having both a ‘‘hit’’ and a ‘‘miss,’’
which are the pixels:
c
A ⊗ (S, T) = (A S) ∩ (A T) (EQ 3.22)