Exercises

  1. Generate 1,000 random numbers ri between 0 and 1. Decide on a bin size and then take a histogram of 1/ri.

  2. Take three images of a hand in each of the three lighting conditions discussed in the text. Use cvCalcHist() to make an RGB histogram of the flesh color of one of the hands photographed indoors.

  3. As in exercise 2, gather RGB histograms of hand flesh color. Take one of the indoor histogram samples as your model and measure EMD (earth mover's distance) against the second indoor histogram and against the first outdoor shaded and first outdoor sunlit histograms. Use these measurements to set a distance threshold.

  4. Using your collection of hand images, design a histogram that can determine under which of the three lighting conditions a given image was captured. Toward this end, you should create features—perhaps sampling from parts of the whole scene, sampling brightness values, and/or sampling relative brightness (e.g., from top to bottom patches in the frame) or gradients from center to edges.

  5. Assemble three histograms of flesh models from each of our three lighting conditions.

  6. Create a flesh-region interest (or "attention") detector.

    1. Just indoors for now, use several samples of hand and face flesh to create an RGB histogram.

    2. Use cvCalcBackProject() to find areas of flesh.

    3. Use cvErode() from Chapter 5 to clean up noise and then cvFloodFill() (from the same chapter) to find large areas of flesh in an image. These are your "attention" regions.

  7. Try some hand-gesture recognition. Photograph a hand about 2 feet from the camera, create some (nonmoving) hand gestures: thumb up, thumb left, thumb right.

    1. Using your attention detector from exercise 6, take image gradients in the area of detected flesh around the hand and create a histogram model for each of the three gestures. Also create a histogram of the face (if there's a face in the image) so that you'll have a (nongesture) model of that large flesh region. You might also take histograms of some similar but nongesture hand positions, just so they won't be confused with the actual gestures.

    2. Test for recognition using a webcam: use the flesh interest regions to find "potential hands"; take gradients in each flesh region; use histogram matching above a threshold to detect the gesture. If two models are above threshold, take the better match as the winner.

    3. Move your hand 1–2 feet further back and see if the gradient histogram can still recognize the gestures. Report.

  8. Repeat exercise 7 but with EMD for the matching. What happens to EMD as you move your hand back?

  9. With the same images as before but with captured image patches instead of histograms of the flesh around the hand, use cvMatchTemplate() instead of histogram matching. What happens to template matching when you move your hand backwards so that its size is smaller in the image?