Developed as a project for the Digital Image Processing and Applications course at Harokopio University of Athens – Dept. of Informatics and Telematics, this project focuses on advanced topics in image processing, compression, and feature extraction. It is divided into four exercises, each tackling a different aspect of computer vision and multimedia systems, including edge detection, lossless compression, image classification, and content-based image retrieval (CBIR).
All implementations are done in Python using libraries such as NumPy, OpenCV, scikit-image, and scikit-learn.
Objective: Detect the main edges of grayscale images (leaf.jpg, X-ray.jpeg, parking-lot.jpg) using three different methods.
- Design, describe, and apply three edge detection methods (e.g., Sobel, Canny, Laplacian of Gaussian).
- For each image:
- Display the original grayscale version.
- Generate the best binary edge masks from each method.
- Provide a detailed explanation of:
- Method choice
- Parameter selection
- Result interpretation and comparison
Objective: Implement the Shannon-Fano compression algorithm from scratch and compare it with Huffman coding.
- Apply Shannon-Fano encoding to
airplane.jpgandbridge.jpg. - For each image, compute and present:
- The codewords (mapping grayscale values to binary codes).
- The average codeword length.
- The entropy of the image.
- The achieved compression ratio.
- Compute the compression ratio using Huffman coding as well.
- Compare and comment on the performance of Shannon-Fano vs. Huffman.
Dataset: Animal Image for Recognition (4 classes: Nilgai, Horse, Cow, Water Buffalos).
- Convert images from
chcek\\chcekandtest\\testfolders to grayscale. - Extract global features:
- Co-occurrence matrix (GLCM)
- Local Binary Pattern (LBP)
- Histogram of Oriented Gradients (HoG)
- Transform each 2D feature into a 1D vector by concatenating rows.
- Use the following representative prototype images for classification:
cow_1001.jpghorse_1001.jpegnilgai_1001.jpegbuffelo_1001.jpeg
- Define similarity between images as the Euclidean distance between feature vectors.
- Classify each image from the
test\\testset based on minimum distance to prototypes. - Compute classification accuracy for each feature type.
- Provide example classification results with similarity metrics.
Dataset: Chess Pieces Detection Images Dataset (5 classes: Queen, Rook, Bishop, Knight, Pawn).
- Task A: Convert all dataset images to grayscale and extract local SIFT (Scale-Invariant Feature Transform) features.
- Task B: Implement a Bag of Visual Words (BoVW) model to create a global feature vector for each image.
- Task C: For a set of representative query images, retrieve the top-10 most similar images from the dataset by computing the Euclidean distance between their BoVW feature vectors.
- Task D: Compute the retrieval accuracy and provide a qualitative analysis of the retrieval results for 2-3 queries.
- Python 3
- NumPy and SciPy – Matrix and numerical operations
- Matplotlib – Visualization of images and results
- scikit-image – Edge detection, LBP, and GLCM utilities
- scikit-learn – K-means for BoVW vocabulary creation
- OpenCV – Feature extraction (SIFT, HoG) and image processing
- Pillow – Image loading and manipulation
- Edge Detection demonstrates the trade-offs between different operators. The Canny detector proved most robust for general-purpose edge finding, while methods like Sobel were simpler but more sensitive to noise.
- Image Compression analysis shows that while both Shannon-Fano and Huffman are effective lossless algorithms, Huffman coding consistently provides a slightly better or equal compression ratio due to its more optimal codeword assignment strategy.
- Image Classification results highlight how different features capture distinct image properties. HoG was effective at describing shape, LBP excelled at texture, and GLCM captured spatial texture relationships, leading to varying classification accuracies across the animal dataset.
- The CBIR System successfully retrieved visually similar images using the BoVW model. This approach effectively summarizes complex local features (SIFT) into a global histogram, enabling efficient content-based similarity search, with accuracy dependent on vocabulary size and feature distinctiveness.
The majority of the images used in this project were sourced from publicly available datasets on Kaggle:
-
Clone this repository:
git clone <https://github.com/AthosExarchou/Digital-Image-Processing-and-Applications-Project_2.git> cd <Digital-Image-Processing-and-Applications-Project_2>
-
Install dependencies:
pip install -r requirements.txt
-
Run each exercise script individually (examples):
python exercise_1_edge_detection.py python exercise_2a_shannon_fano.py python exercise_2b_huffman_comparison.py python exercise_3a_extract_features.py python exercise_3b_classify_images.py python exercise_3c_evaluate_accuracy.py python exercise_4_cbir_bovw.py
- Name: Exarchou Athos
- Student ID: it2022134
- Email: it2022134@hua.gr, athosexarhou@gmail.com
This project is licensed under the MIT License.