cupnoise.gif shown in Figure 5. We used the segmentation program from
Project 1 to separate the object from its background at a threshold
value of 90, as shown in Figure 6. run match.pgm
Segmenting the image cupnoise.gif with a threshold
value of 90 left some salt noise in the black background and
created pepper noise in the object, as can be seen by comparing Figure 5 and Figure 6.
Applying the 5 x 5 mean filter completely removed the noise in the
image, although it made the image slightly blurry. Segmenting this image
yielded very little noise and separated the cup completely from the dark
background, resulting in the best image (Figure 8).
The 7 x 7 closing removed the most of the noise from the image, although
it left the image appearing "splotchy". This accounts for the image
in Figure 9. It is somewhat lighter in color
than the original image shown in Figure 5. The
colors do not blend uniformly either.
Thresholding this image shows that the 7 x 7 closing was unable to remove
the salt noise in the background which looked the same as the background
in the raw segmented image (Figure 6).
For the second part, using the mean filter on the image
cupnoise.gif successfully eliminated all noise in the
image. Although it left the edges of the object blurry, it produced the
best looking segmented image in the bunch. The mean filter appears to be
the best overall filter because it can eliminate both salt and pepper
noise for segmentation. When applying the 7 x 7 closing operator to the
image, it effectively removed the pepper noise from the cup, but did
nothing to remove salt noise from the background. To get rid of the salt
noise, an opening operator would have had to be applied.
The file image.h is the header file for
the class of functions that we designed in C++.
The file image.cc is the implementation
file for the class of functions that we designed in C++.
The file main.cc is the driver file for our program to compare images.
Note: Special run scripts are necessary to execute the code.
For a complete copy of the code, scripts, and images, click here.
After you have downloaded the file:
All images are 256 x 256.
Figure 1: Original image
match.gif Figure 2: Skeletonization applied to
Figure 1
Figure 3: 3 x 3 closing applied to
Figure 1 (Stem disappears)
Figure 4: 7 x 7 closing applied to
Figure 1 (Horn disappears)

Figure 5: Original Image
cupnoise.gif Figure 6: Image segmentation (threshold = 90)
applied to Figure 5

Figure 7: 5 x 5 Mean filter applied to
Figure 5
Figure 8: Image segmentation (threshold = 90)
applied to Figure 7
Figure 9: 7 x 7 Closing operator applied
to Figure 5
Figure 10: Image segmentation (threshold = 90)
applied to Figure 9
Source code:
gunzip -c project2.tar.gz | tar -xvf -"
./run images/match1.gif" to execute the code