CS5760 Pattern Recognition - Project 2
- Eugenie Mangon - Setup + Tasks 1-4
- Ishika Gupta - Tasks 5-7 + Extension
Time travel days used: 1
Implementation of a content-based image retrieval (CBIR) system using multiple feature extraction methods:
- Baseline matching (7x7 center square with SSD)
- Color histogram matching (RGB histogram with histogram intersection)
- Multi-histogram matching with spatial layout (top/bottom halves)
- Texture and color features (Sobel gradient magnitude + RGB histogram)
- Deep network embeddings (ResNet18)
- C++17 compiler (clang++)
- OpenCV 4.x
- macOS with Homebrew (Apple Silicon)
# Clean previous builds
make clean
# Compile all programs
make allProject-2/
├── bin/ # Compiled executables
│ ├── baseline # Task 1: Baseline feature extraction
│ ├── histogram # Task 2: Color histogram extraction
│ ├── multi_histogram # Task 3: Multi-histogram extraction
│ ├── texture_color # Task 4: Texture+color extraction
│ ├── custom # Task 7: Custom feature extraction
│ ├── banana # Extension: Banana detection
│ ├── bluebin # Extension: Blue bin detection
│ ├── face # Extension: Face detection
│ ├── gui # Extension: GUI application
│ └── query # Query program for all methods
├── data/ # Image database
│ ├── olympus/ # Olympus image dataset (1106 images)
│ └── resnet18_embeddings.csv # Task 5: Pre-computed ResNet18 features
├── include/ # Header files
│ ├── csv_util.h # CSV reading/writing utilities
│ └── features.h # Feature extraction functions
├── src/ # Source files
│ ├── baseline.cpp # Task 1 implementation
│ ├── histogram.cpp # Task 2 implementation
│ ├── multi_histogram.cpp # Task 3 implementation
│ ├── texture_color.cpp # Task 4 implementation
│ ├── custom.cpp # Task 7 implementation
│ ├── banana.cpp # Extension: Banana detection
│ ├── bluebin.cpp # Extension: Blue bin detection
│ ├── face.cpp # Extension: Face detection
│ ├── gui.cpp # Extension: GUI application
│ ├── query.cpp # Query program
│ ├── features.cpp # Feature extraction implementations
│ └── csv_util.cpp # CSV utilities
├── results/ # Query results and analysis
├── Makefile # Build configuration
└── README.md # This file
Method: 7×7 center square (147 features)
Distance Metric: Sum of Squared Differences (SSD)
cd src
make clean
make baseline
cd ../bin./baseline ../data/olympus features_baseline.csv./query ../data/olympus/pic.1016.jpg features_baseline.csv baseline 4Method: RGB color histogram (8 bins per channel = 512 bins)
Distance Metric: Histogram intersection
cd src
make clean
make histogram
cd ../bin./histogram ../data/olympus features_histogram.csv 8./query ../data/olympus/pic.0164.jpg features_histogram.csv histogram 4 8Method: Spatial RGB histograms (top + bottom halves, 1024 features)
Distance Metric: Weighted histogram intersection - 0.5 each
cd src
make clean
make multi_histogram
cd ../bin./multi_histogram ../data/olympus features_multi_histogram.csv 8./query ../data/olympus/pic.0274.jpg features_multi_histogram.csv multi_histogram 4 8Method: RGB histogram (512) + Sobel magnitude histogram (16) = 528 features
Distance Metric: Weighted histogram intersection - 0.5 each
cd src
make clean
make texture_color
cd ../bin./texture_color ../data/olympus features_texture_color.csv 8 16./query ../data/olympus/pic.0535.jpg features_texture_color.csv texture_color 4 8./query ../data/olympus/pic.0535.jpg features_histogram.csv histogram 4 8
./query ../data/olympus/pic.0535.jpg features_multi_histogram.csv multi_histogram 4 8Method: ResNet18 embeddings (512-dimensional feature vectors)
Distance Metric: Cosine distance or SSD
cd src
make clean
make query
cd ../bin./query ../data/olympus/pic.XXXX.jpg ../data/resnet18_embeddings.csv dnn 4Note: ResNet18 features are pre-computed and stored in data/resnet18_embeddings.csv. No separate feature extraction program is needed for this task.
Objective: Compare the performance of deep network embeddings (Task 5) against classical feature extraction methods (Tasks 1-4).
Use the query program with different feature files to compare results:
# Compare same target image across all methods
./query ../data/olympus/pic.XXXX.jpg features_baseline.csv baseline 10
./query ../data/olympus/pic.XXXX.jpg features_histogram.csv histogram 10 8
./query ../data/olympus/pic.XXXX.jpg features_multi_histogram.csv multi_histogram 10 8
./query ../data/olympus/pic.XXXX.jpg features_texture_color.csv texture_color 10 8
./query ../data/olympus/pic.XXXX.jpg ../data/resnet18_embeddings.csv dnn 10Method: Custom feature extraction combining multiple approaches
Distance Metric: Custom distance metric
cd src
make clean
make custom
cd ../bin./custom ../data/olympus features_custom.csv./query ../data/olympus/pic.XXXX.jpg features_custom.csv custom 4Method: Custom feature extraction optimized for blue recycling bin identification
cd src
make clean
make bluebin
cd ../bin./bluebin ../data/olympus features_bluebin.csv./query ../data/olympus/pic.XXXX.jpg features_bluebin.csv bluebin 4###Banana Detection Method: Custom feature extraction optimized for banana identification
cd src
make clean
make banana
cd ../bin./banana ../data/olympus banana_features.csv./query ../data/olympus/pic.XXXX.jpg banana_features.csv banana 4cd src
make clean
make hsv_moments
cd ../bin./hsv_moments ../data/olympus features_hsv_moments.csv./query ../data/olympus/pic.XXXX.jpg features_hsv_moments.csv hsv_moments 4cd src
make clean
make lbp
cd ../bin./lbp ../data/olympus lbp_features.csv./query ../data/olympus/pic.XXXX.jpg lbp_features.csv lbp 4cd src
make clean
make bluebin
cd ../bin./bluebin ../data/olympus bluebin_features.csv./query ../data/olympus/pic.XXXX.jpg bluebin_features.csv bluebin 4Method: Custom feature extraction optimized for face identification
cd src
make clean
make face
cd ../bin./face ../data/olympus features_face.csv./query ../data/olympus/pic.XXXX.jpg features_face.csv face 4Interactive visual interface for image retrieval
cd src
make clean
make gui
cd ../bin./gui./query <target_image> <feature_csv> <method> <N> [bins]Parameters:
target_image: Path to query imagefeature_csv: Pre-computed feature databasemethod:baseline,histogram,multi_histogram,texture_color,custom,dnn,banana,bluebin, orfaceN: Number of top matches to returnbins: (Optional) Number of bins per channel (default: 8, only for histogram-based methods)
Examples:
./query ../data/olympus/pic.0164.jpg features_histogram.csv histogram 3 8
./query ../data/olympus/pic.1016.jpg features_baseline.csv baseline 5
./query ../data/olympus/pic.0535.jpg ../data/resnet18_embeddings.csv dnn 10macOS (Apple Silicon)
Visual Studio Code
- All feature extraction programs process the entire olympus dataset (1106 images)
- Feature CSV files are saved in the project root directory
- Query program works with any pre-computed feature file
- ResNet18 embeddings are pre-computed and do not require a separate extraction step
- Extension programs (banana, bluebin, face) use specialized feature extraction for specific object detection tasks