Score: 10 points + 3 Bonus points
Due date: friday, march 3rd (2 weeks !)
A 2-dimensional shape can be defined by its boundary-polygon,which is an ordered list of all coordinates of
its outline points. See the following figure for an example:
The left picture shows the original shape, the middle picture the outline of the shape. We want to create a LIST
of all points of the outline. In order to do so, we start at some arbitrarily chosen point
and traverse the outline clockwise. We store the coordinates of each point in a node, and therefore create an ordered list of x,y-pairs of
coordinates of all boundary vertices, e.g.
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 boundary vertices (points), just 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 way to achieve this is an algorithm called Discrete Curve Evolution (latecki/lakaemper 1999): It keeps the important points, and dismisses unimportant ones. The importance is measured by the amount of visual information 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.
Just for better understanding, here are 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.
Good luck !