Tsury
Tsury

Reputation: 739

A library to detect an image out of an image bank?

Is there an open source/free library for detecting an image out of an image bank? I have ~120 images and I have an input image which is an image from the bank, but maybe slightly cropped/rescaled (not altered in any form though). I'm looking for something that will return the image from the bank with the best similarity to the input image.

Upvotes: 2

Views: 161

Answers (2)

cagatayodabasi
cagatayodabasi

Reputation: 762

I don't know the type of your images, but I assume that they are scenes such as forest, living room, valley, etc. According to Oliva and Torralba, scenes can be represented in terms of low dimensional features which they called the Gist of a scene. By using it, you can get the similar scenes just by using very fast K-Nearest-Neighbor algorithm. They provide a good MATLAB code, but I don't know whether you have MATLAB licence or not. You can check the link below for MATLAB code and original paper.

http://people.csail.mit.edu/torralba/code/spatialenvelope/

Once, I have used the code and here is my results. The biggest picture is input and the smaller ones are the best candidates.

Best candidates from daabase to an input image

I searched a bit and found a C implementation of GIST which is called Lear's GIST implementation; however, I did not use the code. The link is below.

http://lear.inrialpes.fr/software

I hope that this works for you. Happy coding!!

Reference:

Images from http://make3d.cs.cornell.edu/data.html

Gist: http://people.csail.mit.edu/torralba/code/spatialenvelope/

Upvotes: 2

dhanushka
dhanushka

Reputation: 10682

OpenCV is computer vision library that provides interfaces for C/C++, Python and Java. But there's no simple function to accomplish what you want.

A simple approach that might work if your images are gray scale or color would be histogram comparison. Here, you calculate the histograms of the images in the search database, calculate the histogram of the searched image, then compare the distributions using one of the comparison methods. Number of histogram bins will decide the accuracy and performance. If you have a large collection of images, you might want to use higher number of histogram bins to get a good accuracy but it'll cost more time and memory.

Another approach would be to use a feature based technique such as bag-of-visual-words representation of the search and searched images. Here also you can use histogram comparison to compare these representations.

For intersection comparison, you have to normalize the distance measure so you can compare these values. You can divide the distance that you get from the total number of pixels/visual-words of the searched image in this case.

Another techniques that is often suggested for this type of tasks is perceptual hashing, but I don't have any experience using it to comment on its accuracy/performance.

Upvotes: 0

Related Questions