Get Image Contur. How?

Get Image Contur. How?

Post by Eugen Mihailesc » Wed, 09 Feb 2000 04:00:00



Does anybody know how to get the contour for an image?

My problem is the following:
- I have a TImage component containing a TBitmap picture which is set to
transparent. The Bitmap is for instance the shape of a men. I need to get an
array of TPoint that contains all the points which outline the image.

I need this because base on this I want to create a non-rectangular region
for my component.

Thanx,
Eugen

 
 
 

Get Image Contur. How?

Post by Rene Tschaggela » Wed, 09 Feb 2000 04:00:00


You could floodfill the outside. I have a floodfill component
on one of my delphi pages.

Rene
--
Ing.Buero R.Tschaggelar - http://www.ibrtses.com

 
 
 

Get Image Contur. How?

Post by Eugen Mihailesc » Wed, 09 Feb 2000 04:00:00


So, if I'm not wrong, does your component return a TPoint array, because
this is what I need, I suppose...


Quote:> You could floodfill the outside. I have a floodfill component
> on one of my delphi pages.

> Rene
> --
> Ing.Buero R.Tschaggelar - http://www.ibrtses.com

 
 
 

Get Image Contur. How?

Post by Remco de Kort » Thu, 10 Feb 2000 04:00:00



> So, if I'm not wrong, does your component return a TPoint array,
> because
> this is what I need, I suppose...



> > You could floodfill the outside. I have a floodfill component
> > on one of my delphi pages.

> > Rene
> > --
> > Ing.Buero R.Tschaggelar - http://www.ibrtses.com

How about just scanning the image?
Pixel by pixel.
I don't know if you can use an array for this or you should know how
large it should be in advance (or make it large enough anyway).

Remco

http://www.xs4all.nl/~remcodek/download.html

 
 
 

Get Image Contur. How?

Post by bsmith6.. » Thu, 10 Feb 2000 04:00:00




Quote:> So, if I'm not wrong, does your component return a TPoint array,
because
> this is what I need, I suppose...

No it doesn't return a TPoint array, but it is an excellent component.
In fact, I used the Grassfill version of fill and it does return an
array of values that could be used to easily create a contour (i.e.,
edges) but it does not return those points in the correct order that
you would need for a TPoint list.

The problem comes in returning an array of TPoints that perfectly
outlines the image.  I have been beating my brains for months on this.
I have used fuzzy logic, and region fill and frame to no avail.  This
seems to be a very difficult problem.

In may case I am trying to emulate a 'magic wand' type tool that will
return an array of TPoints representing the contour of the area.  I use
the afforementioned Grassfill to capture the relevant pixels (+/- a
tolerance value) and it works great.  But how to return that array of
TPoints????

--Brien Smith

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

Get Image Contur. How?

Post by Rene Tschaggela » Thu, 10 Feb 2000 04:00:00


It can be modified this way. It marks the connected points on an array.
In a second pass you can retrieve just the outline.

Rene
--
Ing.Buero R.Tschaggelar - http://www.ibrtses.com

 
 
 

Get Image Contur. How?

Post by bsmith6.. » Thu, 10 Feb 2000 04:00:00


Quote:> It can be modified this way. It marks the connected points on an
array.
> In a second pass you can retrieve just the outline.

Rene,

First of all, thanks for posting information on your outstanding
Grassfire Fill alogorithm.

Now, to the problem at hand :)

1. Your algorithm (unmodified) will place a one pixel (Integer = -1)
contour OUTSIDE of the actual set of target pixels (surrounding the
real contour).  Also, where the edge of the screen is detected, no
contour will be marked.
2. it is true that the points in the Height x Width array
are 'connected' but to develop an ordered TPoint array you would
somehow have to start a given point in the array and traverse the
points until you reach the starting position again.  In other words,
the array data must be placed in the appropriate sorted order.

An easy way to draw a contour is to convert the pts to a region and
then call FrameRgn.  However, the problem still exists that that line
must be converted to an ordered array of TPoints.

I have developed many algorithms that do just 'ok' but will get lost in
complex concave polygons or in 1 pixel wide fingers that extend
diagonally.  On the other hand, traversing a convex polygon (or bitmap
in this case) is a relative simple task.

This problem is more difficult than it first appears.

--Brien Smith

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

Get Image Contur. How?

Post by Gruh » Mon, 14 Feb 2000 04:00:00


Quote:> I need to get an array of TPoint that contains all the points which

outline the image.

I don't have anything which does this,

Quote:> I need this because base on this I want to create a non-rectangular region
> for my component.

But I do have something which does this. You may be able to make it work for
you. It does require that the parts of the image outside the region be a
special colour.

http://www.hwb.com/gruhn/programming/tutorial/clear.html now has full
projects and explanations for transparent applications.

 - gruhn