【问题标题】:SURF features in EmguCv: how to extract a fixed number of featuresEmguCv 中的 SURF 特征:如何提取固定数量的特征
【发布时间】:2013-04-14 10:42:45
【问题描述】:

我想训练一个神经网络,以便对不同类别的灰度图像进行分类。

作为这个网络的输入,我想使用 SURF-128 算法提取的特征。以下代码(example provided with EmguCV library 的简化版)展示了我如何使用 API:

SURFDetector surfCPU = new SURFDetector(500, true);
VectorOfKeyPoint observedKeyPoints;

BriefDescriptorExtractor descriptor = new BriefDescriptorExtractor();

observedKeyPoints = surfCPU.DetectKeyPointsRaw(img, null);
Matrix<Byte> observedDescriptors = descriptor.ComputeDescriptorsRaw(img, null, observedKeyPoints);

通过使用以下代码:

observedDescriptors.Save(@"SURF.bmp");

我可以保存一些结果。下图是上面代码提取不同大小的特征(右边是上一行代码保存的结果):

我想要的是获得一个固定大小的向量。

如何使用 EmguCV 库为 C# 提供的 API 转换 128 维数组中的通用灰度图像?

【问题讨论】:

    标签: c# emgucv surf


    【解决方案1】:

    问题解决了。

    为了获得一个描述灰度图像的 128 维数组,其中存储了与固定关键点(例如图像中心)相关的特征,我使用了以下代码:

    SURFDetector surfCPU = new SURFDetector(400, true);
    
    float x = 30, y = 50; //KeyPoint position
    float kpSize = 20;    //KeyPoint size
    
    MKeyPoint[] keyPoints = new MKeyPoint[1];
    keyPoints[0] = newMKeyPoint(x, y, kpSize); //This method is written below
    
    ImageFeature<float>[] features = surfCPU.ComputeDescriptors<float>(img, null, keyPoints);
    
    float[] array_of_128_elements = features[0].Descriptor;
    

    private static MKeyPoint newMKeyPoint(float x, float y, float size)
    {
        MKeyPoint res = new MKeyPoint();
        res.Size = size;
        res.Point = new PointF(x, y);
        //res.Octave = 0;
        //res.Angle = -1;
        //res.Response = 0;
        //res.ClassId = -1;
    
        return res;
    }
    

    【讨论】:

      猜你喜欢
      • 2011-07-25
      • 2017-09-12
      • 1970-01-01
      • 1970-01-01
      • 2011-01-10
      • 1970-01-01
      • 2011-07-29
      • 2016-06-16
      • 2013-07-25
      相关资源
      最近更新 更多