Giter Site home page Giter Site logo

adityashaha / cbir-using-cdh Goto Github PK

View Code? Open in Web Editor NEW
13.0 2.0 8.0 2.68 MB

The project is an attempt to implement the paper Content Based Image Retrieval using Color Difference Histogram by Guang-Hai Liu et all. in Python

Jupyter Notebook 98.07% Python 1.93%

cbir-using-cdh's Introduction

Image Retrieval using Color Difference Histogram

Implementation of Content Based Image Retrieval Process based on Color Difference Histogram described by Guang-Hai Liu et al. in the paper using Python. The project was done under the guidance of Prof. Naveen Kumar N

Color Difference Histogram

Color Difference Histogram (CDH) method counts the perceptually uniform color difference between two points under different backgrounds with regard to colors and edge orientations in L*a*b* colorspace because the visual perceptual differences between two colors in L*a*b* colorspace are related to a measure of Euclidean distance while R, G and B components are highly correlated, and therefore, chromatic information is not directly fit for use. CDH also takes into account the spatial layout without any image segmentation, learning processes or any clustering implementation.

Algorithm

The steps involved in the CDH are:

  • Convert the image to L*a*b* colorspace image
  • Edge orientation detection in L*a*b* colorspace because if the gradient magnitude and orientation are detected based on the gray-scale image, much chromatic information will be lost.
  • Use the Sobel operator for detection (because it is less sensitive to noise and has a small computational burden).
  • Color quantization in the L*a*b* colorspace we quantize the L* channel into 10 bins and the a* and b* channels into 3 bins; therefore, 10*3*3 = 90 color combinations are obtained.
  • Feature Extraction: only edge orientations and color index values that are the same are selected to calculate the color difference histogram,rather than all of them.

Canberra distance is taken as the distance measure over Euclidean or Manhattan distance, because the distances in each dimensions are squared before summation, placing great emphasis on features that are greatly dissimilar.

Color Difference Histogram algorithm can be considered as an improved Multi-Texton Histogram (MTH) because it considers the same neighboring colors and edge orientations as texton types and is not just limited to four special texton types.

Repository Structure

  • Color Difference Histogram-A.ipynb: Jupyter Notebook used for explaining code for extracting features using color difference histogram of an input image
  • CBIR Using Color Difference Histogram - Retrieval.ipynb: Jupyter Notebook used for explaining code for retrieval of image from the MongoDB database.
  • CDH.py: Python code responsible for extracting the features from the images and seeding it into MongoDB database.
  • dump/CDHCorel: Folder containing the actual dump (108 bin feature-vector for each image) of the seeded images in the database. It can be restored as:
cd dump/CDHCorel/
mongorestore --db db_name .
  • Corel10k : The images dataset downloaded from the link given below. Download the dataset and put all the images in the directory named Corel10k which is made in the same folder as the notebook that you are executing.

Dataset used

Dataset used for the project is Corel-10k dataset which contains 100 categories, and there are 10,000 images from diverse contents such as sunset, beach, flower, building, car, horses, mountains, fish, food, door, etc. Each category contains 100 images of size 192×128 or 128×192 in the JPEG format. The dataset can be downloaded from Corel-10K

Working

Sample Input:

input

The sample input is taken as per the algorithm described above, the processing is taken place. After which the top results which are similar to the query image are returned.

Sample Output:

output1 output2 output3 output4 output5 output6

The outputs are more or less similar except for one (the helicopter photo)which is an outlier but still it is having an accuracy of around about 83% for top 6 images.

cbir-using-cdh's People

Contributors

adityashaha avatar pratikkejriwal avatar raj-esh29 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cbir-using-cdh's Issues

cant access the database via the input image entry

i can't simply access the added CDH json database and Corel image database viah the 'CBIR Using Color Difference Histogram - Retrieval.ipynb' code, i did exactly as you said, saved the database in the mongodb and the folder CDH with the necessary json files are stored there, and then i still get the error below, i dont know what else should i do? and also the images are all separated by _ in middle but you just entered 690 and accessed the image easily, did you rename all of them manually?
image
image

In my code I'm using CDH code to run,but there was a error. I don't know how to fix it.

File "D:\Python\PyCharm\rsir\pyimagesearch\color_CDH.py", line 190, in getHist
ori = maxgrad_and_mingrad_Lab(lab, onum, width, height)
File "D:\Python\PyCharm\rsir\pyimagesearch\color_CDH.py", line 52, in maxgrad_and_mingrad_Lab
G1 = math.sqrt(0.5 * ((gxx + gyy) + (gxx - gyy) * math.cos(2.0 * theta) + 2.0 * gxy * math.sin(2.0 * theta)))
ValueError: math domain error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.