CS 432 Project 5: Mathematical Morphology *
The goal of this project is quite simple to state: build a system
which inputs an image of quarters, dimes, nickels and pennies (against
a green background) and outputs the total monetary value of the
coins. For example, given an image like the one below, your program
should return $1.04. To accomplish this, you will use the mathematical
morphology toolbox, MMACH.**
Technical Background
Consider two point sets, A and B. Set A might be an isolated region of
a binary image (e.g., the result of a thresholding operation). Set B
is termed a structuring element. In mathematical morphology, it
plays a role analogous to a convolution kernel.
The binary image which results from eroding A by B is the set
of points, (x,y), such that if B is translated so that its
center is at (x,y), then B is completely contained in A. The
binary image which results from dilating A by B is the set of
points, (x,y), such that if B is translated so that its center
is at (x,y), then its intersection with A is not empty.***
It is useful to observe the changes in the effect of the erosion and
dilation operations if we add a small hole to A.
Note that the small hole has a huge effect on the result of the
erosion process---it creates a large "gouge" in its side. The
resulting shape is highly asymmetrical and much smaller than it
otherwise would be. How might this affect subsequent erosion
operations? In contrast, the result of the dilation process is
essentially the same as before except that the small hole has been
filled in.
Higher order morphological operations are implemented by applying
lower order operations in sequence. For example, erosion followed by
dilation is termed opening and dilation followed by erosion is
termed closing. What is the effect of closing A with B?
Coin Images
Hints
- It is possible to do this entire project with only 30 glyphs in
Cantata (but don't worry if you use more).
- Binary images are represented as UNSIGNED BYTE with two grey
values, 0 and 255.
- Use Extract with different values (i.e., 0, 1, 2) for the
region origin in the element dimension to pull out the R, G, and B
components of each .ppm image. Note: To accomodate images of
unknown size, make sure that specify region size is unselected in the
width and height dimensions. To pull out a single color band, make
sure that region size is set to 1 in the element dimension.
- Look at the histograms of image "greeness," i.e., G/(R + G + B),
and/or "redness," i.e., R/(R + G + B) for various images. How many
peaks do you see? Can you devise a strategy which will separate the
coins from the background? Can you separate the pennies from the
silver coins?
- You can use Dilation to fill holes.
- N Erosion (or N Dilation) perform N consecutive
erosion (or dilation) operations with the given structuring element.
- You can use Labeling and Print Stats to count the
total number of disconnected regions in an image and assign the
count to a workspace variable.
- You can evaluate an algebraic expression of workspace variables
using the Variables subform found under the Workspace
menu.
- Divide and conquer. First build a system which will count the
pennies. Only after this is working reliably, should you move on to
the quarters, dimes and nickels.
- Images 6-9 are harder than Images 1-5 because the coins sometimes
touch one another.
- There is a particularly elegant solution to this problem (22
glyphs) using Dist. Transf., which computes the distance
transform.
What You Should Hand In
Nothing.
When You Should Hand It In
You will be required to demonstrate your working project to me, by
appointment, sometime during the period, May 1-12. Your grade will be
based on your project's performance on the nine test images.
* This webpage is located at http://cs.unm.edu/~williams/cs432/project5s00.html
** MMACH is written by Junior Barrera, Gerald Jean Francis Banon and
Roberto de Alencar Lotufo.
*** These definitions are adapted from those described in Digital
Image Processing by Ken Castleman.