Boundary-Fill Algorithm
Another approach to area filling is to start at a point inside a region and paint the
interior outward toward the boundary. If the boundary is specified in a single
color, the fill algorithm proceeds outward pixel by pixel until the boundary color
is encountered. This method, called the boundary-till algorithm
A boundary-fill procedure accepts as input the coordinates of an interior
point (x, y), a fill color, and a boundary color. Starting from (x, y), the procedure
tests neighboring positions to determine whether they are of the boundary color.
If not, they are painted with the fill color, and their neighbors are tested. This
process continues until all pixels up to the boundary color for the area have been
tested. Both inner and outer boundaries can be set up to specify an area, and
some examples of defining regions for boundary fill
two methods for proceeding to neighboring pixels from
the current test position.
void boundaryFill4 (int x, int y, int fill, int boundary)
(
int current:
current = getpixel (x, y);
if ((current != boundary) && (current != fill)) {
setcolor (fill);
setpixel (x, y):
boundary~ill4 (x+l, y, fill, boundary);
boundaryFill4 (x-1, y, fill, boundary) :
boundaryFill4 (x, y+l, fill, boundary);
boundaryFill4 (x, y-1, fill, boundary) ;
)
No comments:
Post a Comment