A common operation on images is called "flood fill", which takes three inputs:
1. a row number, x
2. a column number , y
3. a (new) colour d
The flood fill operation starts by changing the colour of the pixel at location ( x , y ) from its original colour c to the new colour d. Then, all neighbouring pixels (i.e. those pixels to the left, right, above and below, of the pixel at ( x , y )) whose colour is also c will have their colour changed to the new colour d and the process continues on the neighbours of the changed pixels until there are no more pixel locations to consider.
I have to write code to perform the flood fill operation using a recursive function and I am fairly lost. This is what I initially tried: