A Content-Based Image Retrieval (CBIR) system built in MATLAB. Given a query image, it searches an image dataset and returns the most visually similar images, ranked by similarity. It combines color and texture features and applies a two-pass filtering pipeline to progressively narrow down results.
This was the final project for FIT3081 Image Processing (2018).
Each image is described by three feature vectors, which are compared against the query image using Euclidean distance:
- Color — an HSV color histogram quantized into a 16×4×4 (256-bin) feature vector, with histogram equalization applied to the value channel.
- Gabor mean — the mean response of a Gabor texture filter.
- Gabor standard deviation — the standard deviation of the Gabor response.
The retrieval pipeline runs in two passes, each of which can be configured to use any of the three features above:
compute features for every image
│
▼
first-pass sort (by chosen feature's Euclidean distance)
│
▼
first-pass similarity + threshold filtering ← discards dissimilar images
│
▼
second-pass sort (by second chosen feature)
│
▼
second-pass similarity + threshold filtering ← discards dissimilar images
│
▼
ranked list of similar images
Euclidean distances are converted to a similarity score in the range 0–1
(where the largest distance in the set maps to 0 and a distance of 0 maps
to 1). Images whose similarity falls below the configured threshold are
filtered out at each pass.
| File | Purpose |
|---|---|
main2.m |
Script version of the full retrieval pipeline. The easiest way to run and understand the system end-to-end. |
goButton.m |
The GUI backend — same pipeline as main2.m, driven by parameters from the app. |
colorHistogram.m |
Computes the 16×4×4 HSV color histogram feature vector. |
myGabor.m |
Applies a Gabor filter to extract texture features. |
euclideanDistance.m |
Euclidean distance between two feature vectors. |
filteringSimilarity.m |
Finds the cut-off index for threshold filtering of a sorted similarity array. |
grs2rgb.m |
Converts grayscale images to RGB (handles single-band images in the dataset). |
| File | Purpose |
|---|---|
app1.mlapp |
MATLAB App Designer GUI for selecting a query image, choosing filters/thresholds, and viewing results. |
Sample image collections used for retrieval: images/, images_1/,
colordataset/, dinosaurs/, dolphin/, and combine set/.
misc/— experimental and superseded scripts (earlier Gabor/HSV attempts, testing utilities).2ndGaborFilter/— additional Gabor filter experiments.IP-Final-Report_CBIR_*.pdf— the project's final report.
- MATLAB with the Image Processing Toolbox (uses
rgb2hsv,rgb2gray,histeq,imresize, etc.). - App Designer (bundled with MATLAB) to open
app1.mlapp.
Open MATLAB in the project root and run:
main2Configuration is set at the top of main2.m:
% Gabor filter parameters
gamma = 1; psi = 0.1; theta = 90; bw = 2.8; lambda = 3.5;
% Standard resolution images are resized to before processing
resolution = [540; 540];
% Filter selection — 1 = color histogram, 2 = Gabor mean, 3 = Gabor std
firstPassFilter = 1;
secondPassFilter = 2;
% Similarity thresholds (0–1) for each pass
firstPassSimilarityThreshold = 0.3;
secondPassSimilarityThreshold = 0.4;
% Query image
queryimg = imread('images/image1.jpg');By default the pipeline searches the images/ folder. When it finishes, inspect
these variables in the MATLAB workspace:
fileNames— the ranked list of matching image paths.similarityValues— per-image similarity scores (columns: color, Gabor mean, Gabor std).euclideanDistances— the raw distances behind those scores.
Open app1.mlapp in MATLAB App Designer (or double-click it) and run the app to
select a query image, choose the first/second pass filters and thresholds, and
browse the retrieved results interactively.
John Goh, Megan Woon — image processing final project.