Ask Your Question
0

Applying HOG on BGR vs Applying HOG on RGB images

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

Macho gravatar image

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

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

THANK YOUU

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

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

kbarni gravatar image

For color to gray conversion the following formula is used:

Gray=0.3R+0.59G+0.11B

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

Comments

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 -0600 )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 -0600 )edit

Question Tools

1 follower

Stats

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

Seen: 1,459 times

Last updated: Jun 21 '18