Question

So, I have image simple like this:

After doing findContours by openCV, I get a vector of curves, which after drawing look like this:

but I want vector of curves which look just like single line and not around figure, like this:

is there an openCV function for that, or should I use another algorithm? what do you suggest?

Thanks

Était-ce utile?

La solution

If I understood your problem correctly, a way to do what you want would be to use a thinning algorithm. You will find an implementation with OpenCV here.

The steps are :

Take the reverse of your image, to get this :

enter image description here

Then apply the thinning algorithm :

enter image description here

Matlab code to do this :

I = imread('image.jpg');
I = ~I;
It = bwmorph(I(:,:,1),'thin',Inf);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top