A good challenge for practicing 2 dimensional array manipulation.
The Challenge
Write a class that will create a data representation of an image in the form of a 2 dimensional array of 0’s and 1’s forming the pixels of the image. Then create a blur method that will cause any of the 1’s in the image to change the pixels to the left, right, above and below to also be 1’s. This method will need to accept an argument that will specify how far to apply the blur effect.
So consider the following image.
Find the 1’s (highlighted in green) and then change the 0’s around those 1’s to also be 1.
Passing in the argument of 2 will blur like so.
My Solution
My solution was to first find the location/coordinates of the 1’s and save them into a new array called blur_coords
. Then iterate over this new array and using the coordinates update the originally image array. This process will repeat based on the number passed to the method.