The left picture shows the original shape, the middle picture the outline of the shape. Starting with a certain
pixel and traversing this outline clockwise, storing each coordinate, creates an ordered list of x,y-pairs of
coordinates of all boundary vertices, e.g.
10 10
11 10
11 11
...
Now take a look at the rightmost picture in the figure above. It shurely shows a very similar shape,
it seems to be an abstracted version of the original boundary. In fact it is. The rightmost picture shows a
certain subset of the original vertices, connected by lines.
In image processing it is a very important task to simplify shapes without changing their general visual appearance.
This can be done, like in the example figure, by detecting a subset of boundary vertices containing visually significant
information (in terms of human visual perception).
A very simple but effective way to achieve this is to assign the amount of visual information to a single vertex in the following way:
The figure above shows a cutout of the boundary, L,P and R a vertices, the lengths of the segments connecting these
vertices are: LP = l1, PR = l2, RL = l3.
(Since someone from Greece long ago defined the length between to
points as the 'euclidean distance', it is given by sqrt((x1-x2)^2 + (y1-y2)^2), as you should know.)
The line LR shown in the figure is not part of the boundary, but we need it's length for the significance measure:
Define the visual significance S of vertex P simply by S(P) = l1 + l2 - l3.
Some properties of this significance measure S(P) of point P:
Now comes the important part: the abstraction. Remember we want to create a subset of the original boundary, i.e.
want to pick out certain 'important' vertices, dropping 'unimportant' ones.
A natural way to do this is the following:
And here's your assignment:
- Read the boundary-list
(DOWNLOAD HERE!)
, given as a textfile of (x,y)-coordinates of boundary vertices, into a
single linked list. You can either use what JAVA offers or define your own list-structure
- Visualize it, connecting the vertices given in the file by lines
- Implement the abstraction-algorithm
- Show the simplified polygon
Your program should take the filename and the desired number of remaining vertices as input, e.g.
'java abstraction shapelist.txt 38' for reading the file 'shapelist.txt' and simplification down to 38 vertices.
Remark:
Score: 5 points
The assignment is due to 4/18/03 (1 week)
EXTENSION ! The assignment is due to 4/25/03 (total of 2 weeks)
Get a bonus point for adding a slider to your application, showing each step of the simplification. Because
a slider can go back and forth, you have to store the results of each single simplification step. This addition will
enhance your experience using lists !
Good luck !