Social Sciences, asked by garry2474, 1 year ago

Give the advantage and disadvantage over scan line and seed fill algorithm

Answers

Answered by Anonymous
11
Polygon Fill Method: Seed Filling: Boundary fill and Flood fill algorithmOctober 5, 2012 by Admin 2 Comments

Seed Filling: In this method a particular seed point is picked and we start filling upwards and downwards pixels until boundary is reached. Seed fill method is of two types: Boundary fill and Flood fill.

Boundary fill algorithm: In Boundary filling a seed point is fixed, and then neighboring pixels are checked to match with the boundary color. Then, color filling is done until boundary is reached. A region may be 4 connected or 8 connected:

Procedure for filling a 4- connected region: Color is specified by parameter fill color (f-color) and boundary color is specified by boundary color (b-color). getpixel() function gives the color of specified pixel and putpixel() fills the pixel with particular color.

boundary_ fill (x,y, f_color, b_color)

{

If  ( getpixel (x,y) != b_color &&  getpixel (x,y) != f_color)

putpixel(x,y,f_color)

boundary_fill( x+1, y, f_color, b_color);

boundary_fill( x, y+1, f_color, b_color);

boundary_fill( x-1, y, f_color, b_color);

boundary_fill( x, y-1, f_color, b_color);

}

}

Flood fill algorithm: There are some cases where the boundary color is different than the fill color. For situations like these Flood fill algorithm is used. Here the process is started in a similar way by examining the colors of neighboring pixels. But instead of matching it with a boundary color a specified color is matched.

Procedure for filling a 8- connected region:

flood_ fill (x,y, old_color, new_color)

{

putpixel(x,y,new_color)

flood_ fill (x+1, y, old_color, new_color)

flood_ fill (x-1, y, old_color, new_color)

flood_ fill (x, y+1, old_color, new_color)

flood_ fill (x, y-1, old_color, new_color)

flood_ fill (x+1, y+1, old_color, new_color)

flood_ fill (x-1, y-1, old_color, new_color)

flood_ fill (x+1, y-1, old_color, new_color)

flood_ fill (x-1, y+1, old_color, new_color)

}

}

Disadvantages of Seed Fill Algorithm:

1) If an inside pixel is in some other color then the fill terminates and the polygon remains unfilled.

2) Seed fill method does not work for large polygons.

Answered by fistshelter
16

The advantages of Scan line algorithm are as follows:=

1) It takes advantage of coherence resulting in fast algorithm.

2) It does require as much storage as depth buffer

3) It only draws visible pixels.

4) This algorithm is common in software.

The disadvantages of Scan line algorithm are as follows:-

1) It is a more complex algorithm.

2) It requires all polygons sent to renderer before drawing.

Similar questions