Description
Challenge 1: Your task is to develop a vision system that recognizes two dimensional objects in images. For example, we might be interested in detecting the
two objects shown in two_objects.png in another image such as
many_objects_1.png. The vision system should not only determine whether the
objects are present in the image, but also compute their positions and orientations.
The recognition pipeline is divided into four sub-parts, each corresponding to a
program you need to write.
a. Write a program named generateLabeledImage.py that converts a graylevel image to a binary image using a threshold value and segments the
binary image into several connected regions:
labeled_img = generateLabeledImage(gray_img, threshold)
Select any threshold that results in “clean” binary images for the gray-level
ones given to you. You should be able to use the same threshold value for all
the images. In the labeled image, the background should be labeled as 0, and
the maximum value of a label should be equal to the total number of objects.
2
(2 points)
b. Write a program named compute2DProperties.py that takes a labeled
image from the previous step and computes properties for each labeled
object in the image. Store these properties in an objects database.
[obj_db, out_img] = compute2DProperties(gray_img,
labeled_img)
The generated object database obj_db should be a 2D matrix, with each
column corresponding to an object and each row corresponding to a
property. The first six rows should correspond to the following properties:
1. Object label,
2. Row position of the center,
3. Column position of the center,
4. The minimum moment of inertia,
5. The orientation (angle in degrees between the axis of minimum inertia and
the horizontal axis, positive = clockwise from the horizontal axis),
6. The roundness.
You can compute any additional properties if you want. However, these
should appear after the six properties mentioned above. Describe the
additional properties in your README file. The computed properties for all
the training objects will serve as your object model database. The output
image out_img should display the positions and orientations of objects on
the original image gray_img. Use a dot or star to annotate the position and a
short line segment originating from the dot for orientation (refer to
demoMATLABTricksFun.py for examples to draw dots, lines, and to save an
annotated image). Apply compute2DProperties.py to the labeled image of
two_objects.png. (5 points)
c. Now you have all the tools needed to develop the object recognition system.
Write a program named recognizeObjects.py that recognizes objects
from the database:
output_img = recognizeObjects(gray_img, labeled_img,
database)
Your program should compare (using your own comparison criteria) the
properties of each object in a labeled image file with those from the object
model database. It should produce an output image, which would display the
positions, and orientations of only the recognized objects on the original
image (using dots and line segments, as before). Using the object database
generated from two_objects.png, test your program on the images
3
many_objects_1.png and many_objects_2.png. In addition, use
many_objects_1.png as your object database and find the corresponding
objects in the other images. In your README file, state the combination
criteria and thresholds that you used. (5 points)
4
References
[1] E. W. Weisstein, “Eigenvalue,” [Online]. Available:
http://mathworld.wolfram.com/Eigenvalue.html.


