Built to order

Content-Based Image Retrieval using Color Histograms

This project builds a content-based image retrieval engine that finds visually similar images with no tags or filenames — only the pixels. A 2×2 spatial RGB histogram plus Sobel edge density forms a 257-dimensional feature vector per image, and queries are ranked by chi-squared histogram distance. It ships with a complete feature-extraction and indexing pipeline, an evaluation harness on the Wang (Corel-1K) benchmark, and a live web demo where you pick any photo and watch the ranked results appear. The retrieval theory, distance metrics and evaluation protocol are documented for a confident

Content-Based Image Retrieval using Color Histograms — project thumbnail preview
More project photos (2)

The problem

Keyword search fails the moment images have no reliable tags — personal photo libraries, surveillance archives and product catalogues all hold millions of untagged pictures. Content-based image retrieval (CBIR) solves this by describing each image with numbers computed from its own pixels and ranking the collection by visual similarity to a query image. This project implements the classical, fully transparent CBIR pipeline end to end: every image is reduced to a 2×2 spatial RGB histogram (256 dimensions) plus Sobel edge density (1 dimension), the vectors are L2-normalized and indexed, and a query is answered by chi-squared distance ranking. A live web demo makes the engine tangible — pick any photo as the query and the app shows the ranked results with similarity scores, while a feature inspector reveals the exact 257-dimensional vector the engine computed. Because every stage is classical and inspectable, the student can explain precisely why each result was returned.

How it works

  1. Each collection image is divided into a 2×2 spatial grid; a 64-bin RGB histogram is computed per cell and concatenated into a 256-D vector.
  2. Sobel edge density (fraction of edge pixels) is appended, forming the final 257-D descriptor, which is L2-normalized and stored in the index.
  3. A query image goes through the identical extraction, guaranteeing query and index vectors live in the same space.
  4. Chi-squared distance is computed between the query vector and every indexed vector; the collection is ranked by ascending distance and the top-K returned.
  5. The evaluation harness replays every benchmark image as a query, marks same-category hits as relevant, and computes Precision@K and mAP.
  6. The fused variant concatenates the 257-D classical vector with a 2048-D CNN embedding before ranking, and the harness measures the improvement.

Tech stack:

  • Python 3, NumPy, OpenCV (feature extraction)
  • scikit-learn (metrics)
  • Jupyter Notebook (evaluation harness)
  • Flask/FastAPI (REST query API)
  • HTML5 + JavaScript (live retrieval demo)
  • Wang image database (Corel-1K)

Dataset & model details

  • Dataset: Wang image database (Corel-1K, James Z. Wang, Penn State) — 1,000 photographs in 10 categories × 100 images (African people, beaches, buildings, buses, dinosaurs, elephants, flowers, horses, mountains, food). Ground truth: same-category images count as relevant for a query.
  • Task: Query-by-example retrieval; input = a query image, output = the collection ranked by visual similarity (top-K list with similarity scores).
  • Model: Classical: 257-D descriptor (2×2 spatial RGB histogram + Sobel edge density), L2-normalized, chi-squared distance ranking. Fused variant: 257-D classical concatenated with a 2048-D CNN embedding, cosine/chi-squared ranking.
  • Metrics: Precision@10 ≥ 0.72 (design target), mAP ≥ 0.65 (design target), Precision@K curves for K = 5/10/20/50, query latency < 300 ms per 1,000 images (expected). No metric is claimed as measured until the evaluation harness runs for the order.
Parameter Value
Feature vector 257-D classical (256 histogram + 1 edge) · 2048-D fused
Distance metric Chi-squared (histograms) / cosine (fused)
Benchmark Wang (Corel-1K): 1,000 images, 10 categories
Precision@10 ≥ 0.72 (design target, not a measured claim)
mAP ≥ 0.65 (design target)
Query latency < 300 ms per 1,000 images (expected)
Index L2-normalized vectors, in-memory
Demo Single-file web app, runs offline after download

Project features

  • [Real histogram-matching engine] 2×2 spatial RGB histograms plus Sobel edge density extracted live from actual pixels — 257-D vectors, L2-normalized, ranked by chi-squared distance. No tags, no filenames, pure visual similarity.
  • [Live retrieval demo] Pick any photo as the query; the engine extracts its features and returns the collection ranked most-similar-first with similarity scores and rank badges.
  • [Feature inspector] Select any image to see its exact RGB histograms (16 bins/channel), edge density and vector norm — the full internals of the engine, exposed.
  • [Pairwise distance matrix] The complete chi-squared distance matrix over the demo collection, showing how the metric separates similar from dissimilar images.
  • [Evaluation harness] Precision@K and mean average precision computed on the Wang (Corel-1K) benchmark with same-category ground truth, in a reproducible notebook.
  • [Deep-fusion variant] The classical 257-D descriptor concatenated with a 2048-D CNN embedding for a fused representation, with the measured gain documented.
  • [Web UI + REST API] The retrieval engine served behind a clean web interface and a query API, as the pipeline diagram in the demo shows.

What is included

  • Complete CBIR engine (ingest, feature extraction, indexing, ranking, serving)
  • Evaluation harness notebook with Precision@K and mAP on Corel-1K
  • Live retrieval + feature inspector + system report web demo
  • Pairwise distance matrix and precision@K-by-feature-set charts
  • Project report PDF (retrieval theory, histogram methods, distance metrics, methodology, results)
  • PPT presentation for final review
  • Viva Q&A preparation document (color spaces, histograms, chi-squared, precision/recall in retrieval)

Limitations & prerequisites

  • Color histograms ignore spatial layout within each grid cell and object semantics — a red car and a red apple can rank as similar; the report discusses this honestly.
  • Precision@10 ≥ 0.72 and mAP ≥ 0.65 are design targets for the evaluation run, stated honestly — the report documents the actual measured figures after the harness runs.
  • The demo collection is a small curated set for interactivity; the full 1,000-image benchmark runs in the evaluation notebook, not in the browser.
  • The fused CNN variant improves semantic matching but adds inference cost — the tradeoff is measured and reported.
  • Retrieval quality depends on the collection: near-duplicate or very dark images compress the distance range.

Frequently Asked Questions

How does it find similar images without tags?

Each image is converted to a 257-dimensional numeric description (spatial color histogram + edge density) computed from its pixels. Similarity is then pure arithmetic — the chi-squared distance between the query's vector and every stored vector.

Why chi-squared distance instead of Euclidean?

Chi-squared is the standard metric for comparing histograms: it normalizes each bin's contribution by the bin magnitudes, so large bins don't drown out small but informative ones. The report derives this choice.

What is the Wang (Corel-1K) dataset?

A 1,000-image benchmark from James Z. Wang's group at Penn State: 10 everyday categories with 100 photos each. Same-category images serve as ground-truth relevant results, making precision measurable.

What does the fused variant add?

Concatenating the 257-D classical descriptor with a 2048-D CNN embedding adds semantic understanding (objects, scenes) that pure color statistics miss. The harness quantifies the Precision@K gain of fusion over classical alone.

Can it search my own photo collection?

Yes — the ingest stage indexes any folder of images into the same vector format, and the REST API answers queries over it. Indexing your own collection is documented as an extension.

Is this project suitable for a final-year project?

Yes — for AI/ML, Computer Science and IT programs. It demonstrates feature engineering, distance metrics, information-retrieval evaluation and a working live search demo. Suitable for B.E./B.Tech final-year projects in AI & Machine Learning, Computer Science and IT.

Components & software requirements
  • Python 3, NumPy, OpenCV (feature extraction)
  • scikit-learn (metrics)
  • Jupyter Notebook (evaluation harness)
  • Flask/FastAPI (REST query API)
  • HTML5 + JavaScript (live retrieval demo)
  • Wang image database (Corel-1K)

Dataset & model details

  • Dataset: Wang image database (Corel-1K, James Z. Wang, Penn State) — 1,000 photographs in 10 categories × 100 images (African people, beaches, buildings, buses, dinosaurs, elephants, flowers, horses, mountains, food). Ground truth: same-category images count as relevant for a query.
  • Task: Query-by-example retrieval; input = a query image, output = the collection ranked by visual similarity (top-K list with similarity scores).
  • Model: Classical: 257-D descriptor (2×2 spatial RGB histogram + Sobel edge density), L2-normalized, chi-squared distance ranking. Fused variant: 257-D classical concatenated with a 2048-D CNN embedding, cosine/chi-squared ranking.
  • Metrics: Precision@10 ≥ 0.72 (design target), mAP ≥ 0.65 (design target), Precision@K curves for K = 5/10/20/50, query latency < 300 ms per 1,000 images (expected). No metric is claimed as measured until the evaluation harness runs for the order.
Delivery information

Built-to-order project. Delivery timeline is shared after order confirmation based on current queue.

Support terms

Complete documentation, setup guide, and viva preparation included. Support for setup and explanation provided.

Download abstract (PDF)

Related guides

All guides
Blueprint-style technical illustration of multiple decision trees voting together into one final predictionStudents with basic Python and pandas skills who want a reliable first classifier for ML coursework and tabular data projects.

Random Forests Explained: Why Decision Trees Vote Better Together

Decision trees are readable but overfit; random forests fix this by training hundreds of varied trees on bootstrapped data with random feature subsets, then letting them vote. This guide explains Gini impurity, bagging, out-of-bag validation and the four hyperparameters that matter, with a complete scikit-learn workflow, honest feature-importance practices, and the mistakes students keep making.

Read guide
Illustration of object tracking showing video frames with bounding boxes and persistent ID labels following people and vehicles, comparing motion prediction and appearance matching.B.E./B.Tech Computer Science and Electronics students building video analytics projects — people counting, vehicle tracking, sports analysis — who have detection working and need

Object Tracking: DeepSORT and ByteTrack Explained

Detection finds objects per frame; tracking keeps their identities across frames. This guide explains tracking-by-detection, Kalman motion models, DeepSORT's appearance embeddings vs ByteTrack's low-confidence box recovery, tracking metrics (HOTA, IDF1, ID switches), and the tuning parameters that determine real-world quality.

Read guide
Illustration of image segmentation showing U-Net's U-shaped encoder-decoder with skip connections producing pixel masks, alongside Mask R-CNN detecting instances with masks.B.E./B.Tech Computer Science and AI/ML students moving from image classification or detection to pixel-level understanding — medical imaging, defect detection, autonomous driving

Image Segmentation: U-Net and Mask R-CNN

When projects need pixel-level answers, segmentation delivers. This guide explains semantic vs instance vs panoptic segmentation, U-Net's encoder-decoder with skip connections, Mask R-CNN's parallel mask head, Dice and IoU evaluation, paired augmentation, and how to choose the right architecture for your data and question.

Read guide
Get a quotation