I have an image (an array of 1000 x 1000 pixels) of 1s and 0s. I was asked to do edge detection, so I wrote this program in C to traverse the figure. My idea was to convert every pixel surrounded by like pixels to white (1) and every pixel surrounded by at least one unlike pixel to black (0). And I used recursion.
This worked when the figure was small but I'm getting a "stack overflow" message with larger figures.
Is there some systematic technique to convert this to a "non-recursive" program - simulating recursion using a user defined stack?