问题
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