The problem looks quite similar to marching squares (
http://en.wikipedia.org/wiki/Marching_squares), the challenge would be repurposing the concept to be able to trace a line around.
Maybe you could attack it in two passes:
Pass 1: Run the marching squares algorithm to generate all the intersection points and categorize all of the cells in your array.
Pass 2: Iterate through the cells, as soon as you hit one with some content, trace the contour generating your line point until you come full circle back to where you started, as you go mark the cells as processed so that you can skip them as you continue iterating.
As a bonus, by using a marching square based approach, you could choose to have more complexity so that instead of always having 45-degree or 90 degree aligned slopes, you could have other slopes too. Although that might not really fit in with your tile editor.