Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The paint fill or floor fill algorithm is implemented in many imageFigure 1 ( a ) shous example of a 8 9 array with various
The paint fill or floor fill algorithm is implemented in many imageFigure a shous example of a array with various cell colors, and Figure b shows its corresponding
array, which is what your program will take as input.
a
b
Figure : Example of an input array. a Cell colors. b Input array to program.
Assume that array indices start from and the topleft cell is
a
b
Figure : Example of output array. a Cell colors. b Output array from program.
editing programs. Given a screen represented by a twodimensional array of colors a point, and a new
color, the algorithm fills in the surrounding area until the color changes from the original color. The D
array is like a graph where the nodes are each cell or pixeli j and edges are between adjacent cell
pixel. For example, i ji ji j and i j
You will implement this algorithm in a program to fill connected, similarly colored areas with a different
color. Your algorithm takes as input four parameters: a D array, a start node, a target color, and a
replacement color. The D arrays elements are colors whose values are RGBYWgX
which refer to red green, blue, yellow, white, grey and black colors. Start node is given as i j where i
is a row index and j is a column index.
Figure a shows example of a times array with various cell colors, and Figure b shows its corresponding
D array, which is what your program will take as input.
Figure : Example of an input times array. a Cell colors. b Input array to program.
Assume that array indices start from and the topleft cell is
If the start node is target color is Bie black and the replacement color is gie grey the
algorithm looks for all nodes in the D array that are connected to the start node by a path of the target
color and changes them to the replacement color. Figure a shows output of the above input as a times
array with black cell colors modified to grey. Figure b is what your program should output for this
input. You should also print a list of cell locations i j in row major order and the total number of cells
modified. For this input,
List of cell locations modified:
Number of cells modified:
Figure : Example of output times array. a Cell colors. b Output array from program.
You must submit the following to receive full credit.
Python or Java script file with comments and structure.
Testcases on which you validated your program. Each testcase must be a testcaseitxt file where
i n are indices to your testcase files. You MUST include at least two testcase files.
Please make sure you handle corner cases, and gracefully error out when you are provided with in
correct inputs, etc. Program crashes or errors or no outputs will be penalized.a
b
Figure : Example of output array. a Cell colors. b Output array from program.
Give me the correct answer which is asked in the question which satisfies all the requirements and check for corner test cases also?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started