A Stackless Floodfill Automaton

(t3x.org)

20 points | by andsoitis 1 day ago

3 comments

  • voidUpdate 25 minutes ago
    How does this deal with one pixel gaps? The algorithm can enter it just fine but there's no space to go back out again, and there doesn't seem to be a system for backtracking, unless I've misunderstood the algorithm
  • hyperhello 44 minutes ago
    The algorithm uses about half a byte per pixel and saves the path it follows. That kind of implies that the stack is still there and present, it’s just bounded to the number of pixels, and could actually be modified to just use a bounded area of the heap. But conceptually it’s easier to follow the way the paper was written. Neat.
  • zimpenfish 1 hour ago
    Huh, that's useful because I had to write a floodfill a couple of days ago and it was a pain in the arse.

    I'll be converting my code to the stackless version toot sweet.

    • brcmthrowaway 1 hour ago
      Why were you needing floodfill?
      • zimpenfish 26 minutes ago
        To find connected regions on a map. I could probably have been smarter about the initial generation and connected things as they were generated (but that has only just occurred to me. Worth a go, I suppose.)