特征点的OpenCV密度 [英] OpenCV density of feature points
问题描述
使用OpenCV SIFT算法,我能够获取2张图像之间的匹配和不匹配特征点.我的解决方案是此处
匹配的(绿色)和不匹配的(红色)特征点的分布如下图所示(我无法显示实际图像.但是该图像主要包含文本)
我想为图像上的匹配点和不匹配点计算密度函数(即给定图像上的nXn区域,密度函数应给出该nXn区域内存在多少个匹配点).我怎样才能做到这一点?
第二,我想计算一个给出图像nXn区域内匹配和不匹配特征点的密度比的函数.我正在Windows 7上使用Python代码,并从最新的OpenCV源代码构建.
Using OpenCV SIFT algorithm i am able to get the matching and non matching feature points between 2 images. My solution is here
The distribution of matched(green) and non-matched(red) feature points is as shown below.(i cant reveal the actual image. but the image contains mostly text)
I want to calculate a density function for the matching and non matching points on an image(i.e. given a nXn area on the image, density function should give how many matching points are present inside this nXn area). How can i do that?
Secondly, i want to calculate a function that gives ratio of densities of matching and non-matching feature points inside a nXn area on the image.
I am using Python code on Windows 7 and build from latest OpenCV source.
推荐答案
要计算匹配和不匹配关键点的密度可以将您的图像划分为给定大小的子正方形,然后在每个正方形上计算两个密度.请参见下面的示例:
To compute the densities of matching and non-matching keypoints you could divide your image in sub-squares of a given size and calculate the two densities on each square. See the example below:
这样可以离散化同一区域表面上的密度.要计算给定正方形的密度,可以执行以下操作:
This would allow to discretize the densities on surfaces of the same area. To calculate the densities of a given square, you can do the following:
- 创建 Rect (x, y,宽度,高度)对应于正方形的对象.
- 遍历所有不匹配的关键点,并检查Rect中有多少包含(您可以使用Rect.
- Create a Rect(x ,y, width, height) object corresponding to the square.
- Loop over all the non-matching keypoints and check how many of them are contained in the Rect (you can use Rect.contains(Point)).
- Repeat the previous step for the matching keypoints.
- Compute the densities (Keypoints per square pixel) like shown in my example picture.
NB 实际上, Rect 仅存在于 OpenCV C ++ 中,因此您可以重新创建 Rect (及其Python中的包含方法)类(虽然不是必需的).
N.B. Actually, Rect only exists in OpenCV C++, so you can re-create a Rect (and its contains method) class in Python if you want (it is not required though).
这篇关于特征点的OpenCV密度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!