문제

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

도움이 되었습니까?

해결책

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);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top