调整渐变直方图的图像大小

时间:2022-02-27 16:55:03

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 :

我的图像大小为150像素高,188像素宽。我打算在这张图片上计算HOG。由于此描述符需要检测器窗口(图像)的大小为64x128,我应该将图像大小调整为64x128然后使用此描述符吗?像这样 :

 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 个解决方案

#1


0  

Unfortunately the openCV HoGDescriptor documentation is missing.

不幸的是,缺少openCV HoGDescriptor文档。

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

在openCV中,您可以更改检测窗口,单元格大小,blockStride和块大小的值。

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. 我想,winSize必须可以被blockSize整除,而blockSize可以被cellSize整除。

  3. 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.
  4. 功能的大小取决于所有这些变量,因此请确保使用相同大小的图像,并且不要更改设置以免遇到麻烦。

#1


0  

Unfortunately the openCV HoGDescriptor documentation is missing.

不幸的是,缺少openCV HoGDescriptor文档。

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

在openCV中,您可以更改检测窗口,单元格大小,blockStride和块大小的值。

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. 我想,winSize必须可以被blockSize整除,而blockSize可以被cellSize整除。

  3. 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.
  4. 功能的大小取决于所有这些变量,因此请确保使用相同大小的图像,并且不要更改设置以免遇到麻烦。