简体   繁体   English

如何使用SIFT功能/描述符作为SVM培训的输入?

[英]How to use SIFT features/descriptors as input for SVM training?

I want to classify MRI images of a brain tumor into benign and malignant using C++. 我想使用C ++将脑肿瘤的MRI图像分为良性和恶性。 I am using SIFT features and the paper I am following clustered them using kmeans before training the SVM classifier. 我正在使用SIFT功能,接下来我将在培训SVM分类器之前使用kmeans对它们进行聚类。 What I don't understand is why is there a need to do that? 我不明白的是为什么需要这样做? From what I know, kmeans only clusters the features; 据我所知,kmeans仅将特征聚类。 it doesn't change the size of the input. 它不会改变输入的大小。

I have read that possible ways are BoW and histogram. 我已经读过可能的方法是BoW和直方图。 In the histogram approach , It just counts the # of features in each cluster right? 在直方图方法中 ,它仅计算每个聚类中的要素数量,对吗? I don't think that will provide the information I'll need for classifying benign and malignant tumors because they can be both small and big. 我认为这不会提供我对良性和恶性肿瘤进行分类所需的信息,因为它们可能既大又小。 In BoW approach , I didn't understand this link . 在BoW方法中 ,我不了解此链接

Basically, I don't know what to do with my SIFT features to use it as input for SVM. 基本上,我不知道如何使用SIFT功能将其用作SVM的输入。 Do I really have to create a dictionary of some sort? 我真的必须创建某种字典吗? I'm begging you, please enlighten me. 我求求你,请赐教。 Thank you very much! 非常感谢你!

I'm not too familiar with OpenCV or SIFT features, but this should be general enough to be useful to all programming languages. 我对OpenCV或SIFT功能不太熟悉,但这应该足够通用才能对所有编程语言都有用。 I will also be describing only the BoW approach below. 我还将在下面仅介绍BoW方法。

Let's assume we had N images. 假设我们有N张图像。 For each image i , we have F number of features, and each feature had D dimensions. 对于每个图像i ,我们有F个特征,每个特征都有D维。 We can put all the features into an array feats , so that it looks like this: 我们可以将所有功能放入数组feats ,使其看起来像这样:

[1, 2, ..., D]
[..., ..., ..., D]
[N*F, ..., ..., D] 

Each row of feats is a feature, with D dimensions, and we have a total of N*F features. 每行feats是一个具有D维的特征,并且我们总共有N*F特征。

In k-means, we take all these features and group them into k clusters. 在k均值中,我们采用所有这些特征并将它们分组为k簇。 Therefore, every single feature is assigned to a single cluster. 因此,每个单个功能都分配给单个群集。 Most k-means functions typically return a matrix C of size kx D , which represents the centroids of the clusters. 大多数k均值函数通常返回大小为kx D的矩阵C ,它表示簇的质心。 This matrix C is the "codebook" or "dictionary" of the k-means algorithm. 该矩阵C是k-means算法的“码本”或“字典”。 Some also return a vector of size N*F which shows which cluster each feature is assigned to (in OpenCv, this is represented by the labels variable in this link: http://www.developerstation.org/2012/01/kmeans-clustering-in-opencv-with-c.html ). 某些人还会返回一个大小为N*F的向量,该向量显示每个功能分配给哪个群集(在OpenCv中,此链接中的labels变量表示: http : //www.developerstation.org/2012/01/kmeans- clustering-in-opencv-with-c.html )。

Since we already have the assignments of all the features, each image i has F features, which can be simply represented by the clusters they belong to. 由于我们已经分配了所有特征,因此每个图像i都具有F特征,可以简单地用它们所属的簇表示。 For example, if the original image was represented as 例如,如果原始图像表示为

[1, 2, ..., D]
[..., ..., ..., D]
[F, ..., ..., D] 

then the image can also be represented simply as a vector: 那么图像也可以简单地表示为矢量:

[1] % Assignment of feature 1
[...]
[F] % Assignment of feature F

Therefore, you can take this vector and form a histogram h of the clusters that are represented. 因此,您可以采用此向量,并形成所表示的群集的直方图h This histogram is the feature vector for the image, which you can later use in the SVM. 此直方图是图像的特征向量,您以后可以在SVM中使用。

PS If you need any further clarification and/or an example, let me know! PS:如果您需要任何进一步的说明和/或示例,请告诉我!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM