How it calculates shape elongation in opencv?

Question!

I have many greyscale images since i have to extract features for comparison. How can i calculate a shape elongation (a basic shape descriptor: http://www.site.uottawa.ca/~mstoj075/Publications_files/elongation-JMIV.pdf) in opencv (better for python version) for feature extraction?

Sample images: 1) https://docs.google.com/file/d/0ByS6Z5WRz-h2cE1wTGJwRnE5YUU/edit 2) https://docs.google.com/file/d/0ByS6Z5WRz-h2UTFCaVEzaHlXRVk/edit 3) https://docs.google.com/file/d/0ByS6Z5WRz-h2NDgySmJ6NnpId0U/edit

By : postgres


Answers

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

cvFindContours()
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