Itseez/opencv — pull request #1639 by seth-planet (2013-10-16 19:52:21+00:00)
Title: Updating STAR detector and FREAK descriptor to work with large and/or 16-bit images

A project that I've been working with involves large, 16-bit, images. The current implementations of the STAR feature detector and the FREAK feature descriptor don't support either large or 16-bit images. I've written a set of changes to support both. Much of the work goes into adding more bits to the integral image when appropriate. I'll discuss what needed doing:
- In STAR, the method of detecting if the matrix was color didn't make sense. I'm using channels() instead of type() now.
- In STAR, he integral image data type needed to be changed for two reasons. If each cell can have the value of 256, the integer type could overflow when the image is greater than 8 megapixels. If you are working with 16-bit imagery imagery instead of 8-bit, this will happen at much smaller image sizes. So, I've used templates to use a 32-bit integer under the normal case, and 64-bit double for large images and/or higher bit depth.
- In STAR, SSE2 is only enabled if the data type is the original 32-bit integer. It was my aim to support the new data types (shorts & doubles) without removing the existing SSE usage.
- In integral(), in sumpixels.cpp, I added templated support for working with 'short' & 'ushort' precision input. As mentioned before, it's appropriate to use double precision when working with 16-bit images (so that's what I did).
- In FREAK, I broke most of computeImpl() into a new function, computeDescriptors(). I did this so I could use templates and thus keep all the data type permutations sane.
- In FREAK, SSE2 is only used if the average value is expected to be an 8-bit number. This is the original usage, and it should be just as fast as before. 16-bit data falls back to the scalar code.
- In FREAK, meanIntensity() now uses templates.
- In FREAK, the return value of meanIntensity() is 'int' instead of 'uchar' for compatibility between possible data types. It should make no speed difference.