I have a two dimensional array with some of the elements marked, in essence like the image below. I want to calculate the points needed to draw an outline around the marked elements. In this case it would be (2,2),(1,2),(1,3),(1,4),(2,4),(3,4),(4,4), etc.
Using a flood fill I can put together a set of elements are on the line, either inside touching, or outside touching, however, the elements will be in an pseudorandom order, rather than in-order going around the perimeter.
Does anyone know of a good to find the perimeter in this situation?