How it calculates shape elongation in opencv?


I have many greyscale images since i have to extract features for comparison. How can i calculate a shape elongation (a basic shape descriptor: in opencv (better for python version) for feature extraction?

Sample images: 1) 2) 3)

By : postgres


Descriptors (shape moments) are created by iterating over a specific shape, and may or may not use the pixel values. The general form you have is this

Accumulator = 0;
for (each pointx in the contour bounding box)
for (each pointy in the contour bounding box)
   if (cvPointPolygonTest((pointx,pointy),mycontour)) //ie the point is not only in the bounding box, but in the actual contour
       Accumulator = Accumulator   MyDescriptor(point,ImageValueAt(point));

Accumulator will contain your shape descriptor value. I can't bother reading your pdf but these integrals on the first page translate into your double loop here.

This video can help you solving your question :)
By: admin