0

I am looking for a way to categorize every pixel of a Mandelbrot image (zoomed out) as "pixel is fully inside", "pixel is fully outside" or "undetermined". "Fully inside/outside" means, that every point inside this pixel also has to be inside/outside. "Undetermined" then of course would mean, there a points that are inside and other points are outside for that pixel.

I would be happy with an "upper bound" for the undetermined pixels. So if a method would give some pixels that are actually fully inside or outside along with real undetermined pixels, this would be fine. But especially every pixel determined as "fully inside" must be fully inside.

I tried several methods of (mainly interior) distance estimation (like in this post), but they all gave inconsistent values. The exterior part isn't really a problem, but for the interior part, everything I tried so far wasn't useful for this particular case. One "naive" approach (that worked well enough for another case) was:

for every pixel computed as inside the set do
{
    if all surrounding pixels are also inside
    {
        mark pixel as inside
    }
    else
    {
        mark pixel as undetermined
    }
}

But this does not work for "deeper grooves", even when used several times in a row. Does anybody know a good method (or variant of distance estimation) to do this (so especially categorizing pixels as "fully inside the set")?

Paul Aner
  • 361
  • 1
  • 8
  • "surrounding pixels" doesn't make sense. Just make one pixel the one point you compute. Lots of existing code out there, it won't hurt to take a look. – Hans Passant May 15 '23 at 18:15
  • I'm quite dure that the op want to know how to caluclate if ALL points in a pixel (which is a area, for finite resolution) are in the set. But I think that that is not a real programming question but a mathematical one, ao the question shouls be asked elsewhere. – gerum May 15 '23 at 18:21
  • @gerum Well, I think almost everything done with the Mandelbrot set is/was mathematical at some point. Maybe someone knows some algorithm that does what I'm looking for... – Paul Aner May 15 '23 at 18:37
  • @HansPassant What doesn't make sense with "surrounding pixels"? I think, it's clear what I mean. If you could calculate every single point surrounding one pixel and everyone is inside/outside the set, every point in the pixel will be inside/outside the set. Taking surrounding points is an approximation and sure - not a very good one - but it works very well for some applications. If you know about existing code out there, I'd greatly appreciate a link. – Paul Aner May 15 '23 at 18:40
  • _"...originally conjectured that the Mandelbrot set is disconnected. This conjecture was based on computer pictures generated by programs that are __unable to detect__ the thin filaments connecting different parts..."_ https://en.wikipedia.org/wiki/Mandelbrot_set – Richard Critten May 15 '23 at 19:27
  • One certain thing is if the function value escapes before you reach the iteration limit, it is fully determined. @HansPassant 'surrounding pixels' makes great sense. There is a narrow region between pixels definitely on the Mset and those possibly not, where the iteration counts seem a bit chaotic. There is the interesting region for a graphical representation. – Weather Vane May 15 '23 at 19:47
  • @RichardCritten Yes, I know. Using the connected-ness of the Mandelbrot set will not neccessarily work on a computer (or it's just an approximation). So probably every method for categorizing pixels might make mistakes. The question is: Is there an algorithm that gives "good enough" (basically everything about the M-set is just "good enough", isn't it)? – Paul Aner May 15 '23 at 19:52
  • @RichardCritten AFAIK the Mset is connected, but as you say a pixel-oriented solution doesn't find the connecting threads. I implement a curve-stitching algorithm (following a contour to avoid iterating the enclosed points), but when close to the Mset (the chaotic region) it can't be avoided that sometimes I 'snip off' a bud because of that thin connection. – Weather Vane May 15 '23 at 19:53
  • @WeatherVane What do you mean by "it is fully determined"? If a pixel escapes, that doesn't mean every point within this pixel does as well... – Paul Aner May 15 '23 at 19:53
  • It does, if you are not close to the 'chaotic' region bordering the Mset. – Weather Vane May 15 '23 at 19:54
  • That's of course true - how ever you would define "not close" ;-) Your curve-stitching algorithm for example sounds interesting: If I could get a "far enough" (but as close as possible) curve around the M-set and then something similar inside, I would have a narrowed down area that I could categorize as "potentially on the border". Something like this would be helpful... – Paul Aner May 15 '23 at 19:57
  • I examined the neighbouring pixels. If they are all within 1 iteration of the present pixel, I considered it 'safe' to stitch the contour around them. I did a similar thing for pixels within the large areas of Mset too: that's where most of the speed gain is to be found, instead of trudging across at maximum iteration, but as said it is possible to incorrectly snip off regions. It depends on the aim: is it near-perfect, or is it quick enough to make a real-time interesting zoom? However in the apparently chaotic region near the Mset, you just have to iterate, and I spent time tuning that. – Weather Vane May 15 '23 at 20:07
  • I forgot to mention that when a contour is stitched, it can be floodfilled. – Weather Vane May 15 '23 at 20:15
  • OK, I understand what you did outside. But inside? Did you calculate some contour of pixels and if all stayed inside you floodfilled? – Paul Aner May 15 '23 at 20:18
  • Yes: inside, if pixels are with X pixels of the 'choatic' interesting region, I find a boundary there too. But back to your [previous comment](https://stackoverflow.com/questions/76256685/categorizing-every-pixel-in-a-mandelbrot-image-as-fully-inside-fully-outside#comment134476913_76256685), if you are doing a doubling zoom, then each pixel expands to 4, and one of them is certainly known if its value escaped. So in those low-lying regions, there is a 25% saving in execution time, wihout considering contours. – Weather Vane May 15 '23 at 21:06

0 Answers0