Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Using openCV distance transform to find width of a curve

I am trying to find width of a curve/line segment using openCV in python. The image on the left is the input image. I just need the maximum width. I read that Distance transform can help give the width. I used distance transform and was able to get the image on the right as a result. Now, I am stuck on how do i get the width of the curve from this result image of distance transform.

My code for distance transform:

dist=cv2.distanceTransform(image,cv2.DIST_L2,3)
cv2.normalize(dist,dist,0,1.0,cv2.NORM_MINMAX)

Image

A solution in python would be highly appreciated. Thanks in advance.

click to hide/show revision 2
None

updated 2018-11-30 01:29:04 -0600

berak gravatar image

Using openCV distance transform to find width of a curve

I am trying to find width of a curve/line segment using openCV in python. The image on the left is the input image. I just need the maximum width. I read that Distance transform can help give the width. I used distance transform and was able to get the image on the right as a result. Now, I am stuck on how do i get the width of the curve from this result image of distance transform.

My code for distance transform:

dist=cv2.distanceTransform(image,cv2.DIST_L2,3)
cv2.normalize(dist,dist,0,1.0,cv2.NORM_MINMAX)

ImageImage

A solution in python would be highly appreciated. Thanks in advance.