# Revision history [back]

### 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.

 2 None berak 32993 ●7 ●81 ●312

### 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)


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