From: <mpo...@ed...> - 2001-09-10 07:27:08
|
>The flood fill algorithm is pretty simple. You pretty much do this per node - >fill it, recurse to any neighbour node (or pixel) with the same value as the >original (doing the same thing). >Ie, in pseudo C code >[code] Of course, this method works, but it's a good recipe for stack overflows... >There is the scan line method, but that basically has a scanline run >(ie, you calculate a vertical/horizontal length that is all the same colour), >but it is essentially the same algorithm (with a bit of a speed up). That one is a lot better, since it does not push values that will not be used... >Where can I find a description of the floodfill algorithm, with some good >C-source? You should consult the archives of comp.graphics.algorithms, and their FAQ also, because the flood fill problem has been discussed numerous time :) You will find source codes in C, Pascal, pseudo code, theorical discussions about the probabilities of having a stack overflow when using specific graphical patterns (try to use Windows paint to fill a picture made of a patterns of dots regularly spaced...) and so on :) http://www.faqs.org/faqs/graphics/algorithms-faq/ http://groups.google.com/groups?as_q=fill&as_oq=flood%20seed&as_ugroup=comp. graphics.algorithms Have fun. Mickael Pointier |