A Stackless Floodfill Automaton

(t3x.org)

17 points | by andsoitis 1 day ago

3 comments

  • voidUpdate 8 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 27 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 51 minutes 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 50 minutes ago
      Why were you needing floodfill?
      • zimpenfish 10 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.)