PDA

View Full Version : Flood Fill Algorithm



CuriosoVB
09-19-2003, 06:00 AM
Hello!

Anybody has a simple algorithm Flood Fill?

Thanks.

yaro_dup1
09-19-2003, 10:57 AM
The simplest recursive (pseudo code):




void fill( int x, int y )
{
if( pixel[x][y]->color == fill_color | | pixel[x][y]->color == boundary_color )
return;
pixel[x][y]->color = fill_color;
fill( x + 1, y );
fill( x - 1, y );
fill( x, y + 1 );
fill( x, y - 1 );
}


[This message has been edited by glYaro (edited 09-19-2003).]

roffe
09-19-2003, 11:13 AM
The filling itself might not be that complicated, but deciding what to fill is. Search google for edge detection algorithms.