0
$\begingroup$

I have two lists of feature vectors calculated from pre-trained CNN for image retrieval task:

Query: FV_Q and Reference FV_R.

>>> FV_R.shape
(3450, 128)

>>> FV_Q.shape
(3450, 128)

I am a little confused between the concept of exhaustive nearest neighbor search and k-nearest neighbor search.

In python, I use from sklearn.neighbors import KDTree to extract top k = 5 similar images from the reference database, given the query image!

Can somebody explain if there might be any similarities/differences between these two concepts?

Am I making a mistake somewhere in my feature vector comparison?

$\endgroup$
0
$\begingroup$

The exhaustive nearest neighbor search performs an exhaustive search of the nearest neighbor (i.e. the closest image or matches, depending on your application). Here an exhaustive search means that you will compare your query image with any other image, or, in the case of feature matching, you will compare every feature of the query image with every other feature of the target/reference image.

The $k$-nearest neighbor search finds the $k$ closest images. You typically do that by first building a KD-tree with your query (or target) image, so that to speed up the search for the $k$-nearest neighbors of your query image.

(Btw, in case you are interested in the concept of feature matching, in OpenCV, the class that you can use to perform an exhaustive search for the matches between two images is the BFMatcher (which stands for Brute Force Matcher), while the class to perform the search with a KD-tree for the k-nearest neighbhours is FlannBasedMatcher).

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.