CBIR is a computer vision technique for retrieving images from a database based on the similarity of their content. The content of an image is usually described by a set of features. The features are extracted from the image and then compared to the features of the images in the database. The images with the most similar features are returned as the result of the search. The features can be color, texture, shape, etc. The most common features are color, texture, and shape. The features are extracted from the image and then compared to the features of the images in the database. The images with the most similar features are returned as the result of the search. The features can be color, texture, and shape.
For each image in the database, we extract the features and store them in a JSON file features.json
. The features are extracted using the following methods:
- RGB: Red, Green, Blue.
- HSV: Hue, Saturation, Value.
- YCrCb: Luminance, Chrominance Red, Chrominance Blue.
- LBP: Local Binary Pattern.
- GLCM: Gray Level Co-occurrence Matrix.
- LPQ: Local Phase Quantization.
- LOG: Laplacian of Gaussian.
- SOBEL: Sobel operator.
- HU: Hu moments.
The query image is the image that we want to search for in the database. The query image is also extracted using the same methods as the database images. The query image is then compared to the images in the database using the features and a metric is calculated for each image in the database. The images are then sorted based on the metric and the images with the lowest distance are returned as the result of the search.
The features are matched using the following metrics:
- Euclidean distance.
- Chebyshev distance.
- Cosine similarity.
- Manhattan distance.
The similarity score is calculated for each image in the database and the images are sorted based on the similarity score. The images with the highest similarity score are returned as the result of the search.
- @FilaliHicham, Applied Mathematics & AI engineering student at ENSIAS.
- @HamzaBamohammed, Applied Mathematics & AI engineering student at ENSIAS
- @BouchraSahri, Applied Mathematics & AI engineering student at ENSIAS
- Clone the repository to your local machine
git clone https://github.com/HamzaBamohammed/cbir
- Install the required dependencies
pip install -r requirements.txt
- Change the images in the database folder
database
with your own images if needed. - Run the indexation script, this will extract the features of the images in the database and store them in a JSON file
features.json
python index.py
- Run the main script, that will open the GUI and you can load the query image and search for similar images in the database.
python main.py