0

I have found this way to calculate elongation basing on image moments

#ELONGATION
def elongation(m):
    x = m['mu20'] + m['mu02']
    y = 4 * m['mu11']**2 + (m['mu20'] - m['mu02'])**2
    return (x + y**0.5) / (x - y**0.5)

mom = cv2.moments(unicocnt, 1)    
elongation = elongation(mom)

How can i calculate elongation of a Convex Hull?

hull = cv2.convexHull(unicocnt)

where 'unicocnt' is a contour that was taken with find contours.

postgres
  • 2,242
  • 5
  • 34
  • 50

1 Answers1

1

By default, convexHull output a vector of indices of points. You have to set the returnPoints argument to 1 to output a vector of points that you can then pass to cv2.moments.

cedrou
  • 2,780
  • 1
  • 18
  • 23
  • there is only hull and clockwise argument – postgres Feb 28 '13 at 12:51
  • 1
    Which version of OpenCV do you use ? [Here is](http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=rect#convexhull) the doc for cv2.convexHull and I can see 4 arguments. – cedrou Feb 28 '13 at 12:59