1

I'm looking for an implementation of thickening and thinning of 1-bit color bitmaps such that the topology, or connectivity, of the images is not altered. That is, if you do thickening just using dilation, two blobs that are near to each other may be joined into a single blob: the type of thickening operation I am looking for would never do this.

Does OpenCV have this out of the box or is there a way to implement it with what OpenCV does offer?

I believe this operation is implemented in Leptonica but would rather not add an additional dependency beyond OpenCV if I do not need to.

I'm using OpenCV from C++ if that matters.

jwezorek
  • 8,592
  • 1
  • 29
  • 46
  • Check out the thinning function from the extended image processing module: https://docs.opencv.org/4.x/df/d2d/group__ximgproc.html#ga37002c6ca80c978edb6ead5d6b39740c – stateMachine Feb 08 '22 at 21:54
  • thinning must maintain the tree structure of the component, so that's checked off. however, I don't believe that opencv has any "thickening". -- I see that [leptonica refers to a paper](http://www.leptonica.org/papers/conn.pdf)... looks implementable. the math foundation makes it look like that's a simple thing to do (thinning/thickening duality). – Christoph Rackwitz Feb 09 '22 at 10:07
  • Yeah it looks like the way Leptonica does it is in terms of iterative hit-or-miss transformations. Since you can do hit-or-miss in OpenCV it should be possible to do the transformations in that paper but the specifics are unclear to me. That is, Leptonica has a generic thin operation in which it uses one of the "good" transformations from that paper with either 4 or 8 cell connectivity and then thickening would be the opposite connectivity applied to the background, but i can't tell exactly which structure elements etc they are using. – jwezorek Feb 11 '22 at 18:38

0 Answers0