This project demonstrate a simple content-based image retrievel(CBIR) system using a k-nearest neighbors algorithm. The Algorithm retrieves similar images froma dataset based on the color histograms f the query image and the dataset images. The custom KNN algorithm uses chi-square distance as a metyric to find the similar images.
- Python 3.7+
- opencv
- Numpy
You can install the requirted libraries with following command: '''pip install opencv-python numpy'''
- Clone the repo
- Place your dataset of images in the folder name 'Object_data' in the project.
- Place the query image in the folder named 'query'
- Run the script, 'cbir_knn.py'
python cbir_knn.py
- 'cbir_knn.py' : THe manin scriop that IMplements the custom k-NN algorithm and retrieves similar images based on color histihgram
- 'query/': Contains the query image
- 'Object_data/': Contains the training dataset.
You can customize the k-NN algorithm by updating the 'k' value and the distance metric function.