Ask Your Question

Applying HOG on BGR vs Applying HOG on RGB images

asked 2018-06-21 03:55:19 -0500

Macho gravatar image

updated 2018-06-21 04:01:22 -0500

Would applying HOG on BGR images differ from applying HOG to RGB images?

I tested it on both images and found slightly difference

First element in the calculated descriptor

 //0.00511908857151866    //BGR
 //0.005074033513665199   //RGB

I know that HOG accepts only Grey scale images and if it is given a colored image HOG internally would convert it into Grey


edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2018-06-21 04:39:33 -0500

kbarni gravatar image

For color to gray conversion the following formula is used:


That's because the human eye doesn't have the same sensibility for different colors.

As the R and B channels don't have the same weight, the gray image will be (slightly) different if you switch the two channels. This affects the gradient values, so the HOG results will differ too.

Anyway, OpenCV uses BGR encoding, so you should stick to that data format.

edit flag offensive delete link more


Would it matter if i trained SVM on BGR then tested on RGB ?

Since it is going to be a mobile application that takes frames in RGB

Macho gravatar imageMacho ( 2018-06-21 07:14:24 -0500 )edit

It's best to use the same type of image for training and classification. Sometimes the SVM can be quite sensible to variations.

Anyway, as HOG works on grayscale images, the best is to convert everything to grayscale (CV_8U). Otherwise use cvtColor to pass from RGB to BGR or vice versa

kbarni gravatar imagekbarni ( 2018-06-21 10:11:27 -0500 )edit

Question Tools

1 follower


Asked: 2018-06-21 03:55:19 -0500

Seen: 930 times

Last updated: Jun 21 '18