Ask Your Question
4

Do inputs of descriptor extractors are required to be grayscale?

asked 2012-07-06 11:15:40 -0600

mega.photo gravatar image

updated 2012-07-06 11:24:55 -0600

Most if not all descriptors extractors (Surf, Orb, etc.) require the input image to be grayscale. Is there a reason? I tried them on color image (RGBA) and it seems that they work just fine. So, do I really need the extra step to convert a RGBA to grayscale to use these extractors?

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
7

answered 2012-07-06 11:48:16 -0600

AlexanderShishkov gravatar image

You really need this step. But some descriptors (for example SURF) contain such code:

CV_Assert(!img.empty() && img.depth() == CV_8U);
if( img.channels() > 1 )
    cvtColor(img, img, COLOR_BGR2GRAY);

So you have not problems with them.

The reason is that these algorithms are designed to obtain the intensity. Also there are some methods for RGB images (see for example OpponentSIFT), when descriptors are calculated for each channel independently.

edit flag offensive delete link more

Comments

Thanks. That explains it all.

mega.photo gravatar imagemega.photo ( 2012-07-06 13:02:01 -0600 )edit
3

answered 2012-07-22 08:47:50 -0600

Maria Dimashova gravatar image

updated 2012-07-23 00:12:32 -0600

Thanks for the question! I think that manual convertion of an image to the needed type is one of the things that break the "features2d" idea about universal pipeline "detector-descriptor-matcher" with easy replacement of algorithms on each stage (including replacement color descriptor by the gray-scale one and vise versa). We have to specify that Feature Detectors and Descriptor Extractors have to convert an image to their type in case of CV_8UC3 image themselves and guarantee this by unit test. I think we'll do it in the next revision.

Now, Alexander is absolutely right, you should to do the manual convertion for safety.

edit flag offensive delete link more

Comments

1

But please note that implicit conversion may result in performance losses. For instance on a mobile platform you should understand what OpenCV does for you, and manual conversion to gray should be the very first step of your algorithm. Otherwise descriptor extractor will reallocate input matrix on every frame, and this is very bad for your speed and accumulator...

Kirill Kornyakov gravatar imageKirill Kornyakov ( 2012-07-23 10:43:35 -0600 )edit
1

answered 2012-08-23 08:35:33 -0600

mrgloom gravatar image

You may be interested in ColorSift

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2012-07-06 11:15:40 -0600

Seen: 4,966 times

Last updated: Aug 23 '12