Harvey Mudd College
Computer Science 153
Assignment 2
Due Monday, September 25, by midnight

Back to Assignment 2, top-level page

Back to Assignment 2, Section 1: Pictures!

Back to Assignment 2, Section 2: Fourier Analysis

Back to Assignment 2, Section 3: Segmentation by Thresholding


Section 4: Operations on binary images

The purpose of thresholding is to create a binary image: certain pixels are part of an object of interest; the others are not. Even if this is done successfully, there may be more work to be done in order to determine what object is in the image, or how many of them there are, or answer a number of other questions. This part of the assignment asks you to start exploring different means for processing images after they've been segmented, i.e., binary images.

"Cleaning Up" a thresholded image

If you put the line

addpath /cs/cs153/matlab/matlabscode/images
into whatever initialization file you use to set up your path in matlab (there is a built-in facility called pathtool, which has received mixed reports from people who have tried it), you will have access to a variety of morphological operators that are provided in Matlab's image processing toolbox.

In addition, you have access to a number of images stored in matlab. To see an image (binary image) of a printed circuit board, for example, type the lines

>>  B = imread('circbw.tif');
>>  imshow(B);
imshow is matlab's image display function; it can handle binary images (imframe does't -- yet).

The built-in erode takes two arguments: a binary image and a binary structuring element, e.g.,

SE = [ 1,1,1,1,1,1,1,1,1 ];
B2 = erode(B,SE);
figure, imshow(B2);
The extra figure puts the new, eroded image into another window, rather than simply overwriting the old one. SE may be two-dimensional. There is a parallel dilate function built in as well.

For this image, construct a script that runs it through a sequence of morphological operators to "clean up" the circuit as much as possible. Show your resulting image (you will need to multiply by 255 before converting to JPEG), and explain (briefly) the reasoning behind your choices.


Results:




Counting Overlapping Objects

In class we discussed a technique for counting the distinct 4-connected components (objects) in a binary image. That algorithm, however, made several assumptions about its input -- for example, that the objects did not have any "holes" or that the individual objects did not overlap. This problem asks you to adapt the algorithm to ease the latter of those requirements, while adding the requirement that the objects under investigation are circles.

In particular, write a matlab function (or script) that takes in a binary image consisting of (possibly touching or slightly overlapping) circles and outputs the number of circles present. You will likely want to use morphological operators to "separate" the touching circles. You may assume that the circles are no bigger nor smaller than those present in the two images circles.tif and circlesm.tif. In addition, you may assume that the circles never overlap more than shown in those two images.


Results:


Back to Assignment 1 index

Possible Extensions