This lab activity is adapted from C++ for You++,Maria and Gary Litvin, Skylight Publishing, Andover, MA, 1998. An image is represented as a two-dimensional array of characters. Elements of the array, called pixels, (picture elements) have values '.' (white) and 'x' (black). An image may have a number of arbitrary shaped blobs, contours, isolated pixels, etc. With each white pixel in an image we can associate a certain white area called the connectivity component of that pixel. This is defined as the set of all white pixels that can be connected to the given pixel with a continuous chain of white pixels.
The AreaFill(..)
function takes a specified white pixel in an image and fills the
connectivity component of that pixel with black, as illustrated below. A pixel
is said to be connected to pixels that are adjacent horizontally or vertically.
Before After .....xx........ .....xx........ ....x..xx...... ....xxxxx...... ....x....xxxx.. ....xxxxxxxxx.. ...x........xxx ....xxxxxxxxxxx ..x...*........ ..xxxxxxxxxxxxx ...x........xx. ...xxxxxxxxxxxx ...x..xxx...x.x ...xxxxxxxxxx.x ...x..x..x.x... ...xxxx..xxx... ...xxxx...x.... ...xxxx...x.... ............... ...............
AreaFill(..)
that will change the matrix. Display the new matrix
to the screen. In writing your recursive function, be sure you remain within the image
boundaries and do not refil pixels that are already black.