0
votes

I have an image in size of 150 pixel in height and 188 pixel in width. I'm going to calculate HOG on this image. As this descriptor needs the size of detector window(image) to be 64x128, Should I resize my image to 64x128 and then use this descriptor? like this :

 Image<Gray, Byte> GrayFrame = new Image<Gray, Byte>(_TrainImg.Size);
 GrayFrame = GrayFrame.Resize(64, 128, INTER.CV_INTER_LINEAR);

I concern resizing may change the original gradients orientation depending on how it is resized since we are ignoring the aspect ratio of the image?

By the way, The image is croped and I can't crop it anymore. It means this is the size of image after cropping and this is my final bounding box.

1
I'm not very familiar with this function, but in matlab I just ran it on an image of size 797x1300 without any question. Resizing doesn't sound right to me. Are you sure the documentation isn't talking about the bin count of the histogram that it's producing? 64 and 128 seem like pretty standard histogram bin sizes for grayscale images. - David Parks
yes, I looked at the documentation hogdescriptor in opencv and found nothing about that. and I looked at the hog article This Paper also, but it didn't mention about that - Elnaz Yousefi

1 Answers

0
votes

Unfortunately the openCV HoGDescriptor documentation is missing.

In openCV you can change the values for detection window, cell size, blockStride and block size.

cv::HOGDescriptor hogDesc;

hogDesc.blockSize = cv::Size(2*binSize, 2*binSize);
hogDesc.blockStride = cv::Size(binSize, binSize);
hogDesc.cellSize = cv::Size(binSize, binSize);
hogDesc.winSize = cv::Size(imgWidth, imgHeight);

Then extract features using

std::vector<float> descriptors;
std::vector<cv::Point> locations;
hogDesc.compute(img, descriptors, cv::Size(0,0), cv::Size(0,0), locations);

Note:

  1. I guess, that the winSize has to be divisible by the blockSize and the blockSize by the cellSize.
  2. The size of the features is dependent on all these variables, so ensure to use images of same size and do not change the settings to not run into trouble.