使用Matlab“extractHOGFeature”在单个点上计算HOG特征。功能 [英] Computing HOG feature on a single point using Matlab "extractHOGFeature" function

查看:1695
本文介绍了使用Matlab“extractHOGFeature”在单个点上计算HOG特征。功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对matlabextractHOGFeature功能感到困惑。我有一个深度图像(370x89)。我想计算图像中单点的HOG。当我给点[i,j]时,它返回空向量(0x36),当我将点[i,j]交换为[j,i]时,函数返回非空向量(1x36)。另外,我在循环中为每个像素[i,j],[j,i]和整个图像分别运行函数并计算非空HOG矢量,令人惊讶的是我得到了不同的数字。让我在下面的例子中解释。

I'm confused with matlab "extractHOGFeature" function. I have an depth image (370x89). I want to calculate HOG on single point in an image. When I give the point[i,j] sometime it returns empty vector(0x36) and when I swap the points[i,j] to [j,i] the function return a non empty vector(1x36). Additionally I ran the function in the loop for every pixel[i,j],[j,i] and whole image separately and count the non-empty HOG vector and surprisingly I got different numbers. Let me explain in the example below.

坐标为[i,j]。

   count=0; 
    mx=imread('abc_gray.png');
    for i=1:size(mx,1)
        for j=1:size(mx,2)
            XY=[i,j];
            hog=extractHOGFeatures(double(mx),XY);
            if ~ isempty(hog)
               count=count+1;
            end 
        end
    end

**Total number of non-empty vector: 5994**

坐标为[j,i]

count=0; 
      mx=imread('abc_gray.png');
      for i=1:size(mx,1)
          for j=1:size(mx,2)
              XY=[j,i];
              hog=extractHOGFeatures(double(mx),XY);
              if ~ isempty(hog)
                  count=count+1;
              end 
          end
      end

**Total number of non-empty vector: 26270**

哪一个是正确的?

推荐答案

extractHOGFeatures 函数接受 x,y 坐标或列,行坐标。这意味着循环的的第二个版本是正确的。您有时会得到空矢量,因为您指定的坐标超出了图像的范围。发生这种情况是因为行和列被翻转,因此有可能超出行或列的维度。另外,根据你的逻辑,你在技术上应该有 370 x 89 = 32930 HOG描述符 - 每个点一个。但是,您必须记住,我们专注于每个点的周围窗口。如果窗口超出给定点的范围,则无法计算HOG描述符。这就是为什么要计算的HOG描述符少于32930的原因。

The extractHOGFeatures function accepts x,y coordinates or column, row coordinates. This means that the second version of the for loop is the correct one. You are getting empty vectors sometimes because the coordinates you are specifying are going out of bounds in the image. This is happening because the rows and columns are flipped so there is a potential to go beyond the dimensions of the rows or columns. In addition, given your logic you technically should have 370 x 89 = 32930 HOG descriptors - one for each point. However, you have to remember that we concentrate on a window surrounding each point. If the window goes out of bounds given the point, then the HOG descriptor cannot be computed. This is why there is less than 32930 HOG descriptors to compute.

此外,在整个图像上运行 extractHOGFeatures 将它与个别点进行比较肯定会给你不同的尺寸。发生的事情是,对于整个图像,存在块步幅,这意味着图像中的单元格之间将存在重叠,因此HOG特征向量的维度将大于您分别计算每个点的HOG描述符。

Also, running extractHOGFeatures on the entire image and comparing this to individual points will definitely give you different sizes. What's happening is that for the entire image, there is a block-stride, meaning that there will be overlap between cells in the image so your dimensionality of the HOG feature vector will be larger than if you were to compute the HOG descriptor of each point separately.

这篇关于使用Matlab“extractHOGFeature”在单个点上计算HOG特征。功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆