【问题标题】:Implementing Naive Bayes Nearest Neighbor (NBNN) in MATLAB在 MATLAB 中实现朴素贝叶斯最近邻 (NBNN)
【发布时间】:2014-12-08 02:41:28
【问题描述】:

几天前我在 CV SO 上发布了这个question,但论坛基本上没有注意到它。我正在尝试在 MATLAB 中实现 NBNN 以对 CIFAR-10 图像数据集进行图像分类。该算法非常简单,我对它的正确性充满信心,但是,我收到的准确率非常糟糕,只有 22-28%。我不确定为什么,我希望有图像分类或算法经验的人能指出我正确的方向。该算法从 SIFT 图像描述符中学习,这可能是它表现不佳的原因之一。 Matlab 只有一个 SURF 特征检测器。根据我的阅读,SURF/SIFT 基本上是等效的。我一直在使用从下面的函数获得的features, (nDescriptros x 64) 来训练我的模型。

points = detectSURFFeatures(rgb2gray(image));
[features,valid_points] = extractFeatures(image,points);

CIFAR 数据集和这种方法的另一个可能问题是图像尺寸过小。每张图片都是 32 x 32 的图片,我相信这使得特征检测变得非常困难。我在detectSURFFeatures() 中尝试过不同的八度设置,但没有任何东西可以使我的准确度超过 28%。

该方法的注释代码如下。这很难理解,但仍然可能会有所帮助。

希望有人可以帮助我。

for i = 3001:4000 %Train on the first 3000 instances and test on the remaining 1000.
    closeness = [];
    for j = 1:10 %loop over the 10 catergories
        class = train(trainLabel==j,:); % Pull out all descriptors that belong to class j
        descriptor = test(test_id==i,:); % Pull out all descriptors for image i
        [idx,dist] = knnsearch(class,descriptor,'K',1); % Find the distance between the descriptors and the closest labeled descriptor in class j.
        total = sum(dist); % sum up distances
        closeness = [closeness,sum(total)]; % append a vector of the image-to-class distances.
    end
    [val,cat] = min(closeness); % Find choose the class that resulted in the lowest, summed distance.
    predLabel = [predLabel;cat]; % Append to a vector of labels.
    i
end

【问题讨论】:

  • 您使用灰度图像检测 SURF 特征,但从原始 RGB 图像中提取特征。这是否按您的预期工作?如果在灰度图像上使用extractFeatures,结果如何?
  • 所以检测特征对我来说一直是一个不确定的领域。我尝试在 32x32 图像上检测冲浪特征,但收到的输出非常稀疏。只会检测到一两个特征,在某些情况下没有检测到特征。在玩过调整大小之后,我意识到图像越大,我收到的特征就越多,所以我最终将图像调整为 256x256,然后再对其进行特征检测。这是我用来提取特征的两行代码。 points = detectSURFFeatures(I); 然后[features,valid_points] = extractFeatures(I,points)

标签: matlab image-processing computer-vision matlab-cvst knn


【解决方案1】:

如果您的图像是 32x32 像素,那么尝试检测兴趣点并不是一个好主意。正如您所观察到的,如果有的话,您将获得很少的功能。对图像进行上采样是一种选择。另一种选择是使用全局描述符,如 HOG (extractHOGFeatures)。

【讨论】:

猜你喜欢
  • 2012-02-21
  • 2012-04-09
  • 2015-02-18
  • 2015-09-16
  • 2018-12-07
  • 2021-04-09
  • 1970-01-01
  • 2015-06-01
  • 2011-12-28
相关资源
最近更新 更多