特征包如何工作? [英] How Bag of Features works?

查看:137
本文介绍了特征包如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定这是否是这个问题的正确论坛,对不起,非常抱歉。

I'm not sure that this is the right forum for this question, I'm sorry otherwise.

我对 Bag of Features 模型,我试图实现以便通过向量表示图像对于一个CBIR项目)。

I'm quite new to the Bag of Features model and I'm trying to implement in order to represent an image through a vector (for a CBIR project).

根据我的理解,给定一个 S $ c> n 图像,假设我们要通过大小 k 的向量表示图像,这些是实现BoF的步骤: / p>

From what I've understood, given a training set S of n images and supposing that we want to represent an image through a vector of size k, these are the steps for implementing BoF:


  1. 对于每个图像 i ,计算一组关键点,将所有图像的描述符集合放在一起,所以现在我们有 D

  2. 执行 k 方法(其中 k D ,现在我们有 k 个集群,每个描述符向量完全属于一个集群。

  3. 定义 iv 作为生成的BoF向量(大小 k )相对于图像 i 。 每个维度都初始化为0.

  4. 对于每个图像 i ,以及对于每个描述符 d 属于 iD ,找出哪个群集 d 属于所有 k 集群。假设 d 属于 j 集群,则 vi [j] ++

  1. For each image i, compute the set of keypoints and from that compute the set of descriptor i-D.
  2. Put all together the set of descriptor from all the images, so now we have D.
  3. Run the k means (where k is defined above) algorithm on D, so now we have k clusters and each descriptor vector belongs exactly to one cluster.
  4. Define iv as the resulting BoF vector (of size k) relative to image i. Each dimension is initialized to 0.
  5. For each image i, and for each descriptor d belonging to i-D, find out which cluster d belongs between all the k clusters. Supposing that d belongs to the j-th cluster, then vi[j]++.

我不清楚的是如何实现第5点,描述符属于哪个集群,,特别是如果我们试图计算BoF向量的图像是查询图像(因此不属于初始数据集)?我们应该找到最近的邻居(1-NN),以了解查询描述符属于哪个集群吗?

What is not clear to me is how to implement point 5., so how do we understand to which cluster a descriptor belongs to, in particular if the image that we are trying to compute the BoF vector is a query image (and so didn't belong to the initial dataset)? Should we find the nearest neighbor (1-NN) in order to understand to which cluster the query descriptor belongs to?

为什么需要这个 -

我正在实现BoF模型以实现CBIR:给定一个查询图像 q ,找到图像数据集中 q 中最相似的图像 i 为了做到这一点,我们需要解决1近似最近邻问题,例如使用 LSH 。问题是LSH中的输入每个图像表示为一个向量,所以我们需要BoF才能做到这一点!我希望现在更清楚为什么我需要它:)

I'm implementing the BoF model in order to implement a CBIR: given a query image q, find the most similar image i of q in a dataset of images. In order to do this, we need to solve the 1-approximate nearest neighbor problem, for example using LSH. The problem is that the input in LSH each image is represented as a vector, so we need the BoF in order to do that! I hope that now it's clearer why I need it :)

请让我也知道,如果我在上述过程中犯了一些错误。

Please, let me know also if I did some mistake in the procedure described above.

推荐答案

你的算法所做的是生成图像的单词的等价物。

What your algorithm is doing is generating the equivalent of words for a image. The set of "words" is not meant to be a final result, but just something that makes it simple to use with other machine learning techniques.

在这个设置中,你可以使用其他的机器学习技巧。从初始特征(来自点1的关键点)生成一组k个群集。
然后通过每个集群中的关键点数量描述每个图像(就像你有一个由长度为k的字典中的单词组成的文本)。

In this setup, you generate a set of k clusters from the initial feature (the keypoints from point 1). Then you describe each image by the number of keypoints that fall in each cluster (just like you have a text composed of words from a dictionary of length k).

点3说,您从traing set图片获取所有关键点,然后运行 k-means算法,找出点之间的一些合理分离。这基本上确定了这些词是什么。

Point 3 says that you take all the keypoints from the traing set images, and run k-means algorithm, to figure out some reasonable separation between the points. This basically establishes what the words are.

所以对于一个新的图像,你需要计算关键点,就像你对训练集,然后使用你已经计算的集群在训练中你找出了你的新图像的特征向量。

So for a new image you need to compute the keypoints like you did for the training set and then using the clusters you have already computed in training you figure out the feature vector for your new image. That is you convert your image into words from the dictionary you've built.

这是一种从图片生成合理的特征向量的方法(如果你的图片是一个部分结果想)。这不是一个完整的机器学习算法。要完成它,你需要知道你想做什么。如果你只是想找到最相似的图像,那么最近邻居搜索应该这样做。如果你想标记图像,那么你需要从特征向量训练一个分类器(如naive-bayes),并使用它来找出查询的标签。

This is all a way to generate a reasonable feature vector from images (a partial result if you want). This is not a complete machine learning algorithm. To complete it you need to know what you want to do. If you just want to find the most similar image(s), then yes a nearest neighbor search should do that. If you want to label images, then you need to train a classifier (like naive-bayes) from the feature vector and use it to figure out the label for the query.

这篇关于特征包如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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