Ask Your Question
0

Finding distance between skeleton and boundary

asked 2018-12-16 21:08:33 -0600

Esh gravatar image

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.

image description

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 flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-12-17 05:37:48 -0600

VxW gravatar image

updated 2018-12-17 06:06:20 -0600

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

edit flag offensive delete link more

Comments

in c++, the LineIterator can be used for this

berak gravatar imageberak ( 2018-12-17 05:52:43 -0600 )edit

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.

Esh gravatar imageEsh ( 2018-12-17 20:09:43 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-12-16 21:08:33 -0600

Seen: 1,880 times

Last updated: Dec 17 '18