Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C language , Image editing programs often use the flood fill algorithm to fill similarly colored connected areas with a new color. Suppose that

In C language , Image editing programs often use the flood fill algorithm to fill similarly colored connected areas with a new color. Suppose that the two-dimensional 88 array of Figure 11.4a represents the pixels of an image, where 0 represents the black color, 1: white, 2: red, 3: green, and 4: blue, while a pixel is similarly colored connected with another, if they have the same color and it is adjacent to it. The similarly colored areas are depicted in Figure 11.4b.

To implement the flood fill algorithm, write a recursive floodfill() function which change the color (i.e., c) of a pixel at a location (i.e., i, j) to a new color (i.e., nc) and then it changes the color of its neighbouring pixels (i.e., the pixels to the left, right, above, and below the pixel at (i, j)) whose color is also c. This process continues recursively on the neighbours of the changed pixels until there are no more pixel locations to consider.

For example, if we choose to change the color of the pixel in the position 0, 0 from black (i.e., 0) to green (i.e., 3), the color of the top-left area of four pixels changes to green, as shown in Figure 11.4c.

Write a program that creates a two-dimensional 88 array of integers and assigns to its elements random values in [0, 4]. Then, the program should read the location of a pixel and a new color and use floodfill() to change the existing color of its similarly colored area with the new one.

image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Spatial Databases 2nd Symposium Ssd 91 Zurich Switzerland August 1991 Proceedings Lncs 525

Authors: Oliver Gunther ,Hans-Jorg Schek

1st Edition

3540544143, 978-3540544142

More Books

Students also viewed these Databases questions

Question

Describe the special logistics of a Web-based merchant in China.

Answered: 1 week ago

Question

Multiply and simplify completely: (5 +4)2

Answered: 1 week ago

Question

Discuss the different types of leadership

Answered: 1 week ago

Question

Write a note on Organisation manuals

Answered: 1 week ago

Question

Define Scientific Management

Answered: 1 week ago

Question

Explain budgetary Control

Answered: 1 week ago

Question

How was your life influenced by those events?

Answered: 1 week ago

Question

Which of these influenced your life most dramatically?

Answered: 1 week ago