Exercises

  1. Load an image with interesting textures. Smooth the image in several ways using cvSmooth() with smoothtype=CV_GAUSSIAN.

  2. Display the filter, creating a 100-by-100 single-channel image. Clear it and set the center pixel equal to 255.

  3. Load an interesting image. Again, blur it with cvSmooth() using a Gaussian filter.

  4. 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.

  5. 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.

  6. 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.

  7. 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.

  8. 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.

  9. Load an image of a scene and convert it to grayscale.

  10. Load an image with many details.

  11. Load an image of a scene. Use cvPyrSegmentation() and display the results.

  12. 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.

    1. Repeat the exercise but use cvAdaptiveThreshold() instead. Set param1=5.

    2. Repeat part a using param1=0 and then param1=-5.