OpenCV density of feature points

 ̄綄美尐妖づ 提交于 2019-12-10 12:18:12

问题


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.


回答1:


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:

  • 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.

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).



来源:https://stackoverflow.com/questions/43820220/opencv-density-of-feature-points

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!