使用 SIFT 特征训练 SVM 分类器 [英] Training of SVM classifier using SIFT features
问题描述
请我喜欢用 SIFT DESCRIPTOR 和 SVM 将一组图像分类为 4 类.现在,使用 SIFT 提取器,我得到了不同大小的关键点,例如 img1 有 100 个关键点,img2 有 55 个关键点......如何使用 matlab 构建给出固定大小向量的直方图
please i like to classify a set of image in 4 class with SIFT DESCRIPTOR and SVM. Now, using SIFT extractor I get keypoints of different sizes exemple img1 have 100 keypoints img2 have 55 keypoints.... how build histograms that give fixed size vectors with matlab
推荐答案
在这种情况下,dense sift 或许是一个不错的选择.
In this case, perhaps dense sift is a good choice.
有两个主要阶段:
第一阶段:创建密码本.
- 将输入图像分成一组子图像.
- 对每个子图像应用筛选.每个关键点将有 128 维特征向量.
- 通过简单地将 k 均值聚类与选定的
k
相结合,对这些向量进行编码以创建一个码本.每个图像将产生一个矩阵 Vi(i <= n
和n
是使用的图像数量来创建代码字.)大小为128 * m
,其中m
是从图像中收集的关键点的数量.因此,K-means 的输入是一个大矩阵 V,由 Vi 的水平连接创建,对于所有i代码>.K-means 的输出是一个矩阵 C,大小为
128 * k
.
- Divide the input image into a set of sub-images.
- Apply sift on each sub-image. Each key point will have 128 dimensional feature vector.
- Encode these vectors to create a codebook by simply applying k-means clustering with a chosen
k
. Each image will produce a matrix Vi (i <= n
andn
is the number of images used to create the codeword.) of size128 * m
, wherem
is the number of key points gathered from the image. The input to K-means is therefore, a big matrix V created by horizontal concatenation of Vi, for alli
. The output of K-means is a matrix C with size128 * k
.
第 2 阶段:计算直方图.
对于数据集中的每个图像,执行以下操作:
For each image in the dataset, do the following:
- 创建一个大小为
k
的直方图向量h
并将其初始化为零. - 按照第 1 阶段的第 2 步应用密集筛选.
- 对于每个关键点的向量,找到其最佳匹配"的索引;码本矩阵中的向量C(可以是欧几里得距离中的最小值).
- 将
h
中该索引对应的bin加1. - 通过 L1 或 L2 规范对
h
进行标准化.
- Create a histogram vector
h
of sizek
and initialize it to zeros. - Apply dense sift as in step 2 in stage 1.
- For each key point's vector find the index of it's "best match" vector in the codebook matrix C (can be the minimum in the Euclidian distance) .
- Increase the corresponding bin to this index in
h
by 1. - Normalize
h
by L1 or L2 norms.
现在 h
已准备好进行分类.
Now h
is ready for classification.
另一种可能性是使用 Fisher 向量而不是码本,https://hal.inria.fr/file/index/docid/633013/filename/jegou_aggregate.pdf
Another possibility is to use Fisher's vector instead of a codebook, https://hal.inria.fr/file/index/docid/633013/filename/jegou_aggregate.pdf
这篇关于使用 SIFT 特征训练 SVM 分类器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!