thinning/skeletonization algorithm with 4 known neighbors
An answer to this question on Stack Overflow.
Question
I am searching for a thinning/skeletonization algorithm which works if I only know 4 neighbors not 8. From all algorithms I could find I assume that I have knowledge about the diagonal neighbors.
So does anybody know about a thinning algorithm which also works if I only know the top, right, bottom, left neighbor?
The outcome should be like this: http://www.cs.ru.nl/~ths/rt2/col/h9/thinning.GIF
These are not what I am looking for: http://upload.wikimedia.org/wikipedia/commons/thumb/9/93/Skel.png/220px-Skel.png The shape should be maintained as in the first example
Answer
I'd suggest using one of the 8-neighbour algorithms, but feeding it dummy information for the diagonal cells or otherwise modifying the part of the algorithm that considers neighbours.
Since you're not too specific about the kinds of things you're looking at it's hard to offer concrete suggestions. Most algorithms will contain a part that looks like this:
for n in neighbours:
do stuff
in which case you need to edit neighbours.
Others will apply some kind of mask or kernel function. Edit that kernel.