Question: An image is represented by a 2-D array of integers, each integer representing the pixel value of the image (from 0 to 65535). Given a
An image is represented by a 2-D array of integers, each integer representing the pixel value of the image (from 0 to 65535). Given a coordinate (sr, sc) representing the starting pixel (row and column) of the image, and a pixel value newColor.
Consider the starting pixel, plus any pixels connected 4-directionally (up, down, left, right) to the starting pixel of the same color as the starting pixel, plus any pixels connected 4-directionally to those pixels (also with the same color as the starting pixel), and so on. Replace the color of all of the aforementioned pixels with the newColor. This is explained in the following steps.

You are required to, return the modified image. Input: In the first line of input you will be given the dimensions of the image n x m. In the second line you will be given the starting pixels row and column and the newColor: sr, sc & nC respectively. Then you will be given the image. Output: You are required to, return the modified image Sample Input: 3 3 1 1 2 1 1 1 1 1 0 1 0 1 Hint: Img is 0-indexed. Sample Output: 2 2 2 2 2 0 2 0 1
using C language and using Recursion
STEP 1 STEP 2 [1, 1, 1], (1, 1, 0], (1, 0, 1], [1, 2, 1], (2) 2, 0], [1, 0, 1], 1 STEP 3 STEP 4 [2, 2 1], [2, 2, 0], [2, 0, 1], [2, 2, 2], [2, 2, 2, 0], [2, 0, 0, 1]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
