I need a flood fill algorithm for using with BufferedImage
and Graphics2D
in Java. I do not need the simple recursive (DFS) or queue (BFS) versions of this algorithm due to their impractically. I need an efficient, practical, and salable version of this algorithm using scan lines method or any other method.
Asked
Active
Viewed 5,261 times
0

moorara
- 3,897
- 10
- 47
- 60
-
It's an O(n^2) problem. Use the queue method. – Wug Nov 09 '12 at 19:55
-
The simple queue method has the insufficient memory problem! – moorara Nov 09 '12 at 19:59
-
1I'm confused. You know you want to use the scanline method. So what do you want us to do? You already have your algorithm. – Kevin Nov 09 '12 at 20:10
-
The described algorithms in Wikipedia or CodeProjet use some tricks such as "jump" that are not workable in Java! – moorara Nov 09 '12 at 20:44
1 Answers
1
seems you're not the 1.st one: Flood fill using a stack however their solution goes for the queue. But as marked as correct, should work in case you won't find anything more efficient.

Community
- 1
- 1

Peter Butkovic
- 11,143
- 10
- 57
- 81