Home All Groups Group Topic Archive Search About

tracing a line in a bitmap?

Author
15 Sep 2006 7:28 AM
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

Author
16 Sep 2006 8:17 PM
GhostInAK
Hello Lars,

If you can identify the corners it should be trivial from there.

-Boo

Show quoteHide quote
> 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
Author
18 Sep 2006 6:00 AM
Lars Netzel
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



Show quoteHide quote
"GhostInAK" <ghosti***@gmail.com> wrote in message
news:c71747b4303018c8a7a13e5e37d0@news.microsoft.com...
> Hello Lars,
>
> If you can identify the corners it should be trivial from there.
>
> -Boo
>
>> 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
>
>
Author
18 Sep 2006 6:32 AM
blheems
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