You are on page 1of 7

CSL582

Object Filling
What is Object Filling

•Set of pixels surrounded by boundary known as object.


•To set the colour inside of object known as object filling.
•To implement the object filling we have to major techniques –
1. Boundary Fill / Seek Fill
2. Flood Fill

To implement these techniques we have to methods. These are


a. Four Way Connected
b. Eight Way Connected
a. Four Connected

•It is the first implementation technique which help to fill the object in four direction at
once.
•It create 4 pixel in four direction at once which is fast technique but have some issues.
a. After set colour in four direction some of direction are un-used.
b. The output is not as good as.
2. Eight Connected

•It is design to solve the problem of 4 connected approach.


•This implementation technique help to fill the object in Eight direction at once.
•It create 8 pixel in eight directions at once which is fast technique and also use every
corner of object to fill.
•It Provide better output then four connected approach.
1. Boundary Fill

•The first method that introduce the concept to fill the object.
•In this method, edges of the polygons are drawn. Then starting with some seed, any point
inside the polygon we examine the neighboring pixels to check whether the boundary
pixel is reached.
•If boundary pixels are not reached, pixels are highlighted and the process is continued
until boundary pixels are reached.
•We can two procedures
a. Boundary fill using Four Connected
b. Boundary fill using Eight Connected
1. Boundary Fill Method

boundary-fill4(x, y, f-color, b-color)


{
if(getpixel (x,y) ! = b-color&&gepixel (x, y) ! = f-color)
{
putpixel (x, y, f-color)
boundary-fill4(x + 1, y, f-color, b-color);
boundary-fill4(x, y + 1, f-color, b-color);
boundary-fill4(x - 1, y, f-color, b-color);
boundary-fill4(x, y - l, f-color, b-color);
}
}
2. Boundary Eight Connected

boundary-fill8(x, y, f-color, b-color)


{
if(getpixel (x,y) ! = b-color&&gepixel (x, y) ! = f-color)
{
putpixel (x, y, f-color)
boundary-fill4(x + 1, y, f-color, b-color);
boundary-fill4(x+1, y + 1, f-color, b-color);
boundary-fill4(x , y+1, f-color, b-color);
boundary-fill4(x-1, y+1, f-color, b-color);
boundary-fill4(x - 1, y, f-color, b-color);
boundary-fill4(x-1, y - 1, f-color, b-color);
boundary-fill4(x + 1, y-1, f-color, b-color);
boundary-fill4(x, y - l, f-color, b-color);
}
}

You might also like