tracing a line in a bitmap?

  • Thread starter Thread starter Lars Netzel
  • Start date Start date
L

Lars Netzel

Hi,

I have by reading thru the bytes of a bitmap and added an edge detection
filter, created an image with more distinct edges. From this I would like to
find a recangle shaped object. How can I determine where in the picture this
recangle shape is and how big it is?

best regards
/Lars
 
Yes, that would be easy but what if I just want to find a line starting from
one pixel. I guess it would have to be some kind of convultion matrix thingy
but at the same time saving the coordinates?

/Lars
 
I helped do this in graduate school a long time ago, so I don't have
any code for an example. But...........

There are edge detection algorithms that you can use to trace the
outline of an object. The algorithm we used was a recursive algorithm
that used the fact that the edge must trace in one of eight ways.
These correspond to the eight directions; ie. N, NE, E, SE, S, SW, W,
and NW.

So you first find an edge. Then you trace around the edge using the
recursive algoithm. This give you a map of the edge.

Then you calculate the first, second, and (if I remember right) third
moments of inertia of this edge map. Again, there are equations to do
this, but I don't have them handy anymore. You can determine shapes by
comparing the ratios of the various moments with the ratios of known
objects.

If you do all this correct, it will not matter if the rectangle is
aligned ordinally or not. That is, the rectangle does not have to be
north-south and east-west. It can be identified however it is placed
on the map.

The big problem was overlapping objects. A circle overlapping a
rectangle gives you an object with unknown moments.

Good luck,
Brian
 
Back
Top