# Finding distance between skeleton and boundary

I am trying to find maximum width of a curve using openCV in python. I used canny edge detector to get the boundaries of the curve. I have then managed to create a skeleton between them as shown by the red line in the attached image. I now need to find distance between this skeleton and the white line segments so that i can multiply the max distance by 2 to get the width. In short, i need the length of the blue line.

I tried using distance transform but i do not have a closed contour so i am getting incorrect width. I also tried dilation followed by erosion to get a closed contour but that changes the width of my curve. Stuck on this for a long time. Any help would be highly appreciated.

edit retag close merge delete

Sort by » oldest newest most voted

Hi,

First I would calculate the normal vector for each white line. Afterwards, iterate for each white point along the corresponding normal vector until a red line is found. Then you have found two corresponding points (a white and a red point) for that you can calulate the euclidean distance.

see e.g.

How to calculate the normal vector of a line

and

Euclidean Distance

Hope it helps

more

can i please have a look at the sample code ? I am a beginner in programming. I am having a tough time trying to understand how what you're saying works.

Official site

GitHub

Wiki

Documentation