NewProggie NewProggie - 10 months ago 66
Python Question

Thinning contour lines in a binary image

I have a binary image with contour lines and need to purify each contour line of all unnecessary pixels, leaving behind a minimally connected line.

Can somebody give me a source, code example or further information for this kind of problem and where to search for help, please?


If you're looking for python implementations, have a look at scikit-image.

One of their examples is essentially your use case.

Alternately, if you wanted to stick to "straight" scipy, you can do this by using successive erosions and dilations using scipy.ndimage. (As @AxezDNyde mentions.)

Edit: Links fixed.