Gradient fill an arbitrary shape from inside to outside edge?
- From: "Dunny" <paul.dunn1@xxxxxxxxxx>
- Date: Thu, 7 May 2009 17:53:45 +0100
Help :-)
Having a very tough time figuring this one out. Let's say I have a circle, and I want to gradient fill it. It's easy enough to start at the centre and then paint all the pixels based on their distance from that point.
But I want to take things a little further - say, a doughnut. Now instead of a central point, there is a central "ring", a circle that sits in the very middle of the actual doughnut - exactly halfway between then outer edge and the inner edge, and pixels are coloured according to their distance from the nearest outside edge and the nearest point on this circle. This again, isn't hard to do when you know where your edges and central points are.
My problem is this - suppose I have a blob that may or may not extrude in several places, and may or may not have holes cut out of it. This blob has been drawn by the user, and so is a 2D, 2-colour image. How do I find the central "high points" in this figure that was represented by the circle in the doughnut, and the central point in the circle?
My current method is this -
1. Find all the edge-pixels (those with a neighbour missing). Store in a list, and remove them.
2. For all remaining pixels, iteratively remove all pixels with a neighbour missing (new edge-pixels). Discard these /unless/ a pixel has no neighbours - make a list of all these (I call them "ridge pixels"). loop step 2 until no pixels remain.
Now, run over the image again - for each pixel, find the nearest edge pixel and the nearest "ridge" pixel. Colour the pixel in question according to the distance between the two points.
This works fine for a circle, less fine for a doughnut (blobs start to appear) and worse for an arbitrary blobby shape with holes - the ridges between holes are not coloured correctly, and ridge pixels adjacent to eachother create darkened lines between them.
An image of what I mean can be found here:
http://paul.dunn.googlepages.com/splurgetest.bmp
Can anyone help?
.
- Follow-Ups:
- Prev by Date: Re: Matrix
- Next by Date: Re: Gradient fill an arbitrary shape from inside to outside edge?
- Previous by thread: Special Track “Computational Bioimaging” within the ISVC09 USA - Announce & Call for Papers
- Next by thread: Re: Gradient fill an arbitrary shape from inside to outside edge?
- Index(es):
Relevant Pages
|