Gradient fill an arbitrary shape from inside to outside edge?



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?



.



Relevant Pages

  • Re: Displaying images on form...
    ... The circle is way too small and placed somewhere bottom right on the ... the aspect ratio of the Form, so it should result in a circular shape, at ... because Windows uses the same number of "pixels per logical inch" for both ... the pixels themselves are not necessarily "square" when measured ...
    (microsoft.public.vb.general.discussion)
  • Re: Drawing Arcs
    ... fast (28 cycles for a normal 131 pixels screen) that it costs less ... So it seems that the header does actually cost a fixed 20ms time, ... I believe this is the last release for full circle drawing, ... both for Arcs & Circles. ...
    (comp.sys.hp48)
  • Re: Does the NikonD700 have image stabilization?
    ... That's 736 pixels per second ... It's all about getting sharp images _all_ the time. ... while you don't leave a circle of <7km radius. ... get a sharp shot, while not asking for 1/6000s or shorter. ...
    (rec.photo.digital.slr-systems)
  • Re: Displaying images on form...
    ... The shape of your circle has got nothing to do with the relationship between ... the aspect ratio of the Form, so it should result in a circular shape, at ... because Windows uses the same number of "pixels per logical inch" for both ... the pixels themselves are not necessarily "square" when measured ...
    (microsoft.public.vb.general.discussion)
  • Re: determing
    ... 2)in my case if you take a look at the scatter plot again at r.koller.yais.net/TM98.png there are also many pixels in the outskirts so the variant finding nearest n neighbours should be ok i guess. ... so it would be an idea just define a threshold on those result values and if they are larger than the threshold the pixel lies in the outskirts and not in the main scatterplot body. ...
    (comp.soft-sys.matlab)