Harvey Mudd College
Computer Science 153
Assignment 4
Due Monday, November 13, by midnight

Back to Assignment 4, top-level page


Section 1: Hough Transform

The Hough transform is a general-purpose method for finding contours with known parameterizations within an image. In this problem, you will be seeking out circles, rather than lines. (Although the extensions suggest more possibilities.)

Part 1: Warm-up with synthetic circles

In the directory

/cs/cs153/Images/a4/synthetic
are several synthetic images of circles with varying amounts of noise added. The name of each image indicates the contents of that image with the following conventions: the name circ3.40.tif is an image containing 3 circles, each of which has radius 40 pixels. (The presence or absence of noise is not indicated in the name.)

Using the Hough transform, design a system that identifies the circles in these synthetic images and overlays a ring of colored pixels around the edges of those circles. In creating your system, consider the following requirements:

For suggestions of approaches on many of these points, see the section "Things to Consider," below.


Results:


Part 2: CD ID

In the directory

/cs/cs153/Images/a4/cds
are several images of CDs taken under various states of occlusion by other objects and each other. Since they are real images, noise is present, and edge detection will not be perfect.

Adapt your circle-finding and highlighting code from the previous section to identify CDs from images. Your code should estimate the number of CDs in an input image, as well as the locations of their centers. You should add some kind of graphical annotation (a dot in the center, a radius from center to edge, a ring encircling the CDs) to indicate where and how many objects were found in the image.

Keep in mind that there will likely be far more circles than CDs in any given image. Also, the centers of some of the CDs may be outside the image. Again, see the list near the end of the assignment for suggestions on handling the parameter space effectively.


Results:


Part 3: Accounting for Change

Imagine building a vision system to handle transactions at a newsstand or a lunch counter. Among the many problems facing your system is the ability to identify and count change. In particular, the change may be partially overlapping (to handle the fully overlapping case, you'd need an arm or an actuator of some sort) and it may be on a surface with considerable distractions in the background (a magazine or newspaper, for instance).

This problem asks you to extend your previous two Hough transforms to output the value of the change visible in an image. In the /cs/cs153/Images/a4/change directory there are several pictures including coins -- try your algorithm out on them. You can assume that the pictures will only have to handle pennies, nickels, dimes, and quarters. However, you can't be sure how far from the camera the coins will be, so that their sizes will not necessarily be known beforehand.

Certainly consider using more information than just the contours provided by the Hough transform for this problem, e.g., color would be an important cue for distinguishing nickels from pennies. Using the relative sizes of the coins (which is known and fixed) is also fair game.


Results:


Things to Consider

As discussed in class, there are a number of factors that contribute to the succes of a Hough transform.
  1. To gain additional accuracy in your localization of circles (or any contour, in general), consider backprojecting the hypothesized curve and then "tweaking" it a bit by fitting it to the edge pixels. For a line, that would mean finding the least-squares (or least-inertia) line that fits the edge pixels near the hypothesized line. For a circle, it would mean simply averaging the coordinates of the pixels near the hypothesized circle to find a better estimate of its center.


  2. Because of error introduced by discretizing parameter space, it often helps to blur the values that are being accumulated there. This, in effect, lets an edge feature contribute evidence not only for curves (circles) going directly though that point, but also for curves passing nearby. This can be done either as evidence is being accrued (by adding to neighboring bins) or afterward, by smoothing accumulator space. The latter might be done by convolving with a Gaussian or another smoothing mask. Matlab's function conv2 does arbitrary 2d convolution. Matlab's fspecial function can create Gaussian masks of any size and any standard deviation.


  3. The distribution of "votes" in parameter space can be complex enough that multiple responses can arise from a single image curve. There are a couple of methods to handle this that you may want to try: Both of these techniques lead to sharper peaks in the accumulator, and thus easier and more robust contour-finding.


  4. The discussion so far has been of binary feature points casting binary votes. Edge images usually have binary feature points because of the thresholding done during edge detection. In many cases it is more effective to use the strength of the gradient magnitude to weight the votes cast in parameter space. You can find the gradient magnitude by estimating the partial derivative of the intensity image in the x- and y-directions and finding the length of the resulting 2x1 vector.


  5. Possible Extensions

    On to Section 2: Final project proposal