-
Flood-Fill function : C
Hi, How are you all! I am the working in the XYZ company, as a C programmer. I have to submit the presentation on the Flood Fill function to my executive. But I don't know anything about the Flood Fill. So, I would like to know about the Flood Fill function. I also would like to know about the Flood Fill function works and what is the algorithm of the Flood Fill function. So, Is there is anyone who can know about the Flood Fill function ? Please, help me!!!!!
-
Flood-Fill function
Hello, Flood fill can also be known as the seed fill. Flood Fill is an algorithm that can determines the area that is connected to a given node in a multi-dimensional array. Flood Fill can be used in the " bucket" fill tool of paint programs. In paint Flood Fill can be used to determine which parts of a bitmap to fill with color and in games like puzzle games such as Magic Drop, Puyo Puyo, Minesweeper, Lumines, Samegame and Magical Drop for determining which pieces are cleared. Flood-Fill can also be known as the Boundary Fill when it is applied on an image to fill a particular area that is bounded with color.
-
Flood-Fill function : C
I think the Flood Fill is an algorithm. The Flood Fill algorithm can takes three parameters such as a start node, a target color, and a replacement color. The Flood Fill algorithm is looking for all the nodes in the an array which are connected to the start node by a path of the target color and changes them to the replacement color. Flood Fill algorithm can be structured in many ways but they all make use of a stack or queue data structure implicitly or explicitly.
-
Flood-Fill function : C
I think you have to carefully see the following line of code of C Program that demonstrates the Implementation of Flood Fill Algorithm :
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<graphics.h>
void fill_right(p,q)
int p , q ;
{
if(getpixel(p,q) == 0)
{
putpixel(p,q,RED);
fill_right(++p,q);
p = p - 1 ;
fill_right(p,q-1);
fill_right(p,q+1);
}
}
void fill_left(p,q)
int p , q ;
{
if(getpixel(p,q) == 0)
{
putpixel(p,q,RED);
fill_left(--p,q);
p = p + 1 ;
fill_left(p,q-1);
fill_left(p,q+1);
}
}
void main()
{
int p , q ,b[10][10];
int ge, gn ,p,j;
detectgraph(&ge,&gn);
initgraph(&ge,&gn,"c:\\tc\\bgi");
printf(" \n\n\tEnter the no. of edges of polygon : ");
scanf("%d",&p);
printf("\n\n\tEnter the cordinates of polygon :\n\n\n ");
for(j=0;j<p;j++)
{
printf("\tP%d Q%d : ",j,j);
scanf("%d %d",&b[j][0],&b[j][1]);
}
b[p][0]=b[0][0];
b[p][1]=b[0][1];
printf("\n\n\tEnter the seed pt. : ");
scanf("%d%d",&p,&q);
cleardevice();
setcolor(WHITE);
for(j=0;j<p;j++)
{
line(b[j][0],b[j][1],b[j+1][0],b[j+1][1]);
}
fill_right(p,q);
fill_left(p-1,q);
getch();
}
-
Flood-Fill function
I think one of the algorithm such implicitly stack-based i.e. recursive flood-fill implementation for a 2-D array as follows:
Flood-fill (node, target-color, replacement-color):
1. If the color of node is not equal to target-color then return.
2. Set the color of node to replacement-color.
3. Perform Flood-fill (one step to the west of node, target-color, replacement-color).
Perform Flood-fill (one step to the east of node, target-color, replacement-color).
Perform Flood-fill (one step to the north of node, target-color, replacement-color).
Perform Flood-fill (one step to the south of node, target-color, replacement-color).
4. Return.
Page generated in 1,713,946,009.36551 seconds with 11 queries