You are on page 1of 1

COMALGO: Machine Project Specification

Second Term, A.Y. 2010-2011

Center of Mass of Images


I. Objective
Practice algorithm design and analysis as expected to be mastered in the course.

II. Problem
A number of algorithms for optical character recognition involve comparison of a scanned
image with templates of the “ideal” characters. One of the difficulties of such algorithms is
deciding where to start comparison as characters in a scanned image are subject to noise and
distortion. One of the procedures widely used in practice is to deal with such changes in
position via matching the center of mass of the scanned image with that of the template.

In this project, you are required to implement this procedure of locating an image’s center of
mass. For simplicity, assume a scanned image has already been represented as a square array
of numbers, which represent the grayscale values of corresponding points in a scanned image.
The center of mass, aij (value at the ith row and jth column) is the element in the array such
that the difference between the sum of the elements of the two array portions above and
below (to the left and to the right of) the ith row (jth column) is minimal.

To illustrate, assume the 5x5 array below contain values from a small image.
0.0 0.1 0.9 0.1 0.0
0.1 0.9 0.2 0.9 0.1 The center of mass for this array is the point in row 3 column 3
0.1 0.9 0.2 0.9 0.1 (0.2 in the middle), for which the difference of the sums is
minimal (3.1 from 3.3 above and 6.4 below; 0 from 3.9 to the left
0.9 0.9 0.8 0.9 0.9 and 3.9 to the right). Note that in general, the center of mass is
0.9 0.1 0.0 0.1 0.9 not necessarily the center of the matrix.

Your implementation should accept a file input containing space-separated values (one line is
to one row) corresponding to a 25x25 image. The output of your program will be a text file
(use the filename “<name_of_input>-output.txt”) containing i, j, and a where i is the row, j is
the column, and a is the value of the point which is the center of mass of the image. Full
marks will be given if your program’s efficiency is O(n2).

III. Deliverables
a. A program that performs the tasks required. (65%)
b. A short written report (Times New Roman, 12pt, 2-3 pages) containing:
i. Your names and ID numbers
ii. Description of your algorithm (pseudocode or plain English) (15%)
iii. Time complexity analysis of your algorithm (20%)
iv. Other information you think are important about your algorithm (extra)

You might also like