Load an image with interesting textures. Smooth the image in several ways using
cvSmooth()
with smoothtype=CV_GAUSSIAN
.
Use a symmetric 3-by-3, 5-by-5, 9-by-9 and 11-by-11 smoothing window size and display the results.
Are the output results nearly the same by smoothing the image twice with a 5-by-5 Gaussian filter as when you smooth once with two 11-by-11 filters? Why or why not?
Display the filter, creating a 100-by-100 single-channel image. Clear it and set the center pixel equal to 255.
Smooth this image with a 5-by-5 Gaussian filter and display the results. What did you find?
Do this again but now with a 9-by-9 Gaussian filter.
What does it look like if you start over and smooth the image twice with the 5-by-5 filter? Compare this with the 9-by-9 results. Are they nearly the same? Why or why not?
Load an interesting image. Again, blur it with cvSmooth()
using a Gaussian filter.
Set param1=param2=9
. Try several settings of
param3
(e.g., 1, 4, and 6). Display the
results.
This time, set param1=param2=0
before setting
param3
to 1, 4, and 6. Display the results. Are
they different? Why?
Again use param1=param2=0
but now set
param3=1
and param4=9
. Smooth the picture and display the results.
Repeat part c but with param3=9
and param4=1
. Display the results.
Now smooth the image once with the settings of part c and once with the settings of part d. Display the results.
Compare the results in part e with smoothings that use param3=param4=9
and param3=param4=0
(i.e., a 9-by-9 filter). Are the results the same? Why or why not?
Use a camera to take two pictures of the same scene while moving the camera as
little as possible. Load these images into the computer as src1
and src1
.
Take the absolute value of src1
minus
src1
(subtract the images); call it diff12
and display. If this were done perfectly,
diff12
would be black. Why isn't it?
Create cleandiff
by using cvErode()
and then cvDilate()
on diff12
. Display the
results.
Create dirtydiff
by using cvDilate()
and then cvErode()
on diff12
and then
display.
Explain the difference between cleandiff
and
dirtydiff
.
Take a picture of a scene. Then, without moving the camera, put a coffee cup in the scene and take a second picture. Load these images and convert both to 8-bit grayscale images.
Take the absolute value of their difference. Display the result, which should look like a noisy mask of a coffee mug.
Do a binary threshold of the resulting image using a level that preserves most of the coffee mug but removes some of the noise. Display the result. The "on" values should be set to 255.
Do a CV_MOP_OPEN
on the image to further
clean up noise.
Create a clean mask from noise. After completing exercise 5, continue by keeping only the largest remaining shape in the image. Set a pointer to the upper left of the image and then traverse the image. When you find a pixel of value 255 ("on"), store the location and then flood fill it using a value of 100. Read the connected component returned from flood fill and record the area of filled region. If there is another larger region in the image, then flood fill the smaller region using a value of 0 and delete its recorded area. If the new region is larger than the previous region, then flood fill the previous region using the value 0 and delete its location. Finally, fill the remaining largest region with 255. Display the results. We now have a single, solid mask for the coffee mug.
For this exercise, use the mask created in exercise 6 or create another mask of your
own (perhaps by drawing a digital picture, or simply use a square). Load an outdoor
scene. Now use this mask with cvCopy()
, to copy an
image of a mug into the scene.
Create a low-variance random image (use a random number call such that the numbers don't differ by much more than 3 and most numbers are near 0). Load the image into a drawing program such as PowerPoint and then draw a wheel of lines meeting at a single point. Use bilateral filtering on the resulting image and explain the results.
Load an image of a scene and convert it to grayscale.
Run the morphological Top Hat operation on your image and display the results.
Convert the resulting image into an 8-bit mask.
Copy a grayscale value into the Top Hat pieces and display the results.
Load an image with many details.
Use cvResize()
to reduce the image by a
factor of 2 in each dimension (hence the image will be reduced by a factor of 4). Do
this three times and display the results.
Now take the original image and use cvPyrDown()
to reduce it three times and then display the
results.
How are the two results different? Why are the approaches different?
Load an image of a scene. Use cvPyrSegmentation()
and display the results.
Load an image of an interesting or sufficiently "rich" scene. Using cvThreshold()
, set the threshold to 128. Use each setting
type in Table 5-5 on the image and display
the results. You should familiarize yourself with thresholding functions because they
will prove quite useful.
Repeat the exercise but use cvAdaptiveThreshold()
instead. Set param1=5
.
Repeat part a using param1=0
and then
param1=-5
.