Skip to content

MazenEwiss/Imaging

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

18 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Satellite Image Feature Extraction System

Road & Building Classification using Digital Image Processing

Cairo University - Faculty of Engineering
Computer Engineering Department
Digital Image Processing Lab - Term Project 2025


πŸ“‹ Project Overview

This project implements a complete satellite image processing pipeline for detecting and classifying roads and buildings from aerial/satellite imagery. The system uses traditional digital image processing techniques (no deep learning in the main pipeline) and outputs results in both raster (PNG) and vector (SVG) formats.

Key Features

  • βœ… SLIC superpixel segmentation for boundary-preserving regions
  • βœ… Region merging to reduce over-segmentation
  • βœ… Road-focused feature extraction (skeleton, linearity, color uniformity)
  • βœ… Adaptive soft-scoring classification (no hard thresholds)
  • βœ… Morphological cleanup for connected road networks
  • βœ… SVG vectorization using Douglas-Peucker line simplification (from scratch)
  • βœ… User-friendly GUI application

πŸ—‚οΈ Project Structure

Imaging/
β”œβ”€β”€ Module1/                    # Input images (satellite/aerial imagery)
β”œβ”€β”€ Module2/
β”‚   β”œβ”€β”€ color/                  # Preprocessed color images
β”‚   └── gray/                   # Preprocessed grayscale images
β”œβ”€β”€ Module3/
β”‚   β”œβ”€β”€ edges/                  # Edge detection results
β”‚   └── segmentation/           # SLIC segmentation results
β”œβ”€β”€ Module4/
β”‚   β”œβ”€β”€ region_features/        # Extracted features per region
β”‚   └── region_clusters/        # Classification results
β”œβ”€β”€ Module5/
β”‚   └── visualization/          # Final PNG visualizations with overlays
β”œβ”€β”€ Module6/                    # Final SVG vector outputs ⭐
β”œβ”€β”€ Module_DL/                  # Deep Learning outputs (optional)
β”‚
β”œβ”€β”€ phase1_preprocessing.py     # Phase 1: Preprocessing (resize, denoise, enhance)
β”œβ”€β”€ phase2_improved.py          # Phase 2: SLIC Segmentation
β”œβ”€β”€ phase3_improved.py          # Phase 3: Feature Extraction
β”œβ”€β”€ phase4_improved.py          # Phase 4: Classification
β”œβ”€β”€ phase5_improved.py          # Phase 5: Visualization
β”œβ”€β”€ phase6_vectorization.py     # Phase 6: SVG Vectorization ⭐
β”œβ”€β”€ phase_dl_classification.py  # Deep Learning comparison (optional) 🧠
β”œβ”€β”€ gui_app.py                  # GUI Application ⭐
β”œβ”€β”€ run_improved_pipeline.py    # Pipeline runner script
└── README.md                   # This file

πŸš€ Installation & Requirements

Prerequisites

  • Python 3.8 or higher (tested on Python 3.12)
  • Operating System: Windows, Linux, or macOS

Required Libraries

Install all dependencies using pip:

pip install numpy opencv-python scikit-image scikit-learn scipy pillow

Complete Library List:

Library Version Purpose
numpy >= 1.21.0 Array operations and numerical computing
opencv-python >= 4.5.0 Image processing (cv2)
scikit-image >= 0.18.0 SLIC superpixels, morphological operations
scikit-learn >= 0.24.0 K-means clustering, StandardScaler
scipy >= 1.7.0 Scientific computing, ndimage operations
pillow >= 8.0.0 Image display in GUI (PIL/ImageTk)

GUI Requirements (Tkinter):

  • Windows: Tkinter is included with Python by default
  • Linux (Ubuntu/Debian):
    sudo apt-get install python3-tk
  • macOS: Tkinter is included with Python by default

Virtual Environment Setup (Recommended)

# Create virtual environment
python -m venv venv

# Activate virtual environment
# Windows:
venv\Scripts\activate
# Linux/macOS:
source venv/bin/activate

# Install dependencies
pip install numpy opencv-python scikit-image scikit-learn scipy pillow

πŸ“– How to Use

Option 1: GUI Application (Recommended) ⭐

Step 1: Activate your virtual environment (if using one)

# Linux/macOS
source venv/bin/activate

# Windows
venv\Scripts\activate

Step 2: Run the GUI application

python gui_app.py

Step 3: Using the GUI

  1. Select an image from the list on the left panel (images from Module1 folder)
  2. Click "β–Ά Start Processing" button in the right panel
  3. Wait for all 6 phases to complete (green checkmarks indicate success)
  4. View results using the tabs: Overlay, Roads, Buildings
  5. Click "πŸ“ Open SVG Output" to open the vector file
  6. Click "πŸ“‚ Open Folder" to browse all output files

Option 2: Command Line Pipeline (All Images)

Process all images in Module1 at once:

python run_improved_pipeline.py

This will:

  1. Process all .jpg, .png, .jpeg, .tif images in Module1
  2. Run all 6 phases sequentially
  3. Save outputs to Module5 (visualizations) and Module6 (SVG files)

Option 3: Process Single Image (Command Line)

Process a specific image by running each phase with the --image flag:

python phase2_improved.py --image your_image.jpg
python phase3_improved.py --image your_image.jpg
python phase4_improved.py --image your_image.jpg
python phase5_improved.py --image your_image.jpg
python phase6_vectorization.py --image your_image.jpg

Option 4: Individual Phases (All Images)

Run each phase separately on all images:

python phase2_improved.py   # SLIC Segmentation
python phase3_improved.py   # Feature Extraction
python phase4_improved.py   # Classification
python phase5_improved.py   # Visualization
python phase6_vectorization.py   # SVG Vectorization

⚑ Quick Start

  1. Place your satellite/aerial images in the Module1/ folder
  2. Run python gui_app.py
  3. Select an image and click "Start Processing"
  4. Find your results in Module6/ (SVG) and Module5/visualization/ (PNG)

πŸ”§ Troubleshooting

Common Issues

Issue Solution
ModuleNotFoundError: No module named 'cv2' Run pip install opencv-python
ModuleNotFoundError: No module named 'skimage' Run pip install scikit-image
_tkinter.TclError: no display name Set display: export DISPLAY=:0 (Linux)
TclError: bad argument "zoomed" Already fixed - update to latest code
Images not appearing in list Check that images are in Module1/ folder
SVG file not opening Install SVG viewer or use a web browser

Linux-Specific Setup

If running on Linux, ensure you have:

# Install Tkinter
sudo apt-get install python3-tk

# Install xdg-utils for opening files
sudo apt-get install xdg-utils

πŸ“Š Pipeline Phases

Phase 1: Preprocessing (phase1.ipynb)

  • Converts input images to color and grayscale versions
  • Applies brightness/contrast normalization (GUI handles this)

Phase 2: Segmentation (phase2_improved.py)

  • Uses SLIC superpixels for boundary-respecting segmentation
  • Merges similar regions based on LAB color distance
  • Removes small noise regions

Phase 3: Feature Extraction (phase3_improved.py)

  • Skeleton features: Length, ratio, linearity (key for roads)
  • Shape features: Compactness, elongation, rectangularity, solidity
  • Color features: Saturation, gray-ness, uniformity
  • Edge features: Internal edge density, boundary strength

Phase 4: Classification (phase4_improved.py)

  • Soft-scoring approach for roads and buildings
  • Roads: High elongation, high linearity, low saturation
  • Buildings: High compactness, high rectangularity, small area

Phase 5: Visualization (phase5_improved.py)

  • Morphological cleanup of road networks
  • Connected component analysis
  • Overlay generation with legend

Phase 6: Vectorization (phase6_vectorization.py)

  • Extracts contours from classification masks
  • Applies Douglas-Peucker line simplification (implemented from scratch)
  • Generates SVG files compatible with mapping tools

🎯 Output Formats

PNG Visualizations (Module5/visualization/)

  • {image}_overlay.png - Classification overlay on original
  • {image}_overlay_with_legend.png - With classification legend
  • {image}_roads_only.png - Binary road mask
  • {image}_buildings_only.png - Binary building mask

SVG Vectors (Module6/)

  • {image}.svg - Scalable vector graphics with roads & buildings
  • {image}_vectorized_overlay.png - Vector overlay preview

πŸ› οΈ Key Algorithms (Implemented from Scratch)

Algorithm File Description
Douglas-Peucker phase6_vectorization.py Line simplification for vector output
Region Merging phase2_improved.py Merge similar adjacent superpixels
Skeleton Features phase3_improved.py Road linearity detection
Soft Scoring phase4_improved.py Adaptive classification without hard thresholds
Morphological Filter phase5_improved.py Road network cleanup

πŸ“ˆ Classification Criteria

Roads

  • βœ… High elongation (> 2.5)
  • βœ… High linearity (long skeleton relative to area)
  • βœ… Low saturation (gray colors)
  • βœ… High color uniformity
  • βœ… Moderate consistent width

Buildings

  • βœ… High rectangularity (> 0.5)
  • βœ… High compactness (circular shape factor > 0.25)
  • βœ… High solidity (convex shape)
  • βœ… Low elongation (< 3.0)
  • βœ… Smaller area (< 6000 pixels)

πŸ‘₯ Team Members

Name Role
[Team Member 1: mohamed emad] Segmentation & Preprocessing
[Team Member 2: mohamed yasser nabil] Feature Extraction
[Team Member 3: mazen hatem] Classification & ML
[Team Member 4: karim yasser] Visualization & GUI

πŸ“š References

  1. Garg, R.D. (2024). Integrated approaches for road extraction and de-noising from high resolution satellite image using adaptive global thresholding and morphological operations.

  2. Chen, Z. et al. (2022). Road extraction in remote sensing data: A survey.

  3. Pang, Z. et al. (2024). A Building Extraction Method for High-Resolution Remote Sensing Images.

  4. Achanta, R. et al. (2012). SLIC Superpixels compared to state-of-the-art superpixel methods. IEEE TPAMI.

  5. Douglas, D.H. & Peucker, T.K. (1973). Algorithms for the reduction of the number of points required to represent a digitized line.


⚠️ Notes

  • This project uses no deep learning in the main pipeline (as per project requirements)
  • A pretrained DNN comparison can be added for bonus marks
  • All non-primitive functions are attributed in the code
  • Output SVG is compatible with GIS/mapping tools

πŸ“„ License

This project is for educational purposes only (Cairo University DIP Lab 2025).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors