Skip to content

MDVR9980/Iranian-License-Plate-Segmentation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Iranian License Plate Character Segmentation

A Computer Vision project designed to isolate and segment the 8 characters of Iranian license plates. This project utilizes Morphological Operations and Geometric Heuristics to achieve high accuracy without the computational weight of Deep Learning models.

📌 Overview

Character Segmentation is a critical step in Automatic License Plate Recognition (ALPR) systems. This project addresses common challenges found in Iranian plates, such as:

  • Shadows & Low Contrast: uneven lighting conditions.
  • Blue Strip Interference: The standard blue flag/strip on the left.
  • Connected Characters: Digits merging due to blur or low resolution.
  • Physical Damage: Broken characters or screw/bolt noise.

Performance:

  • Accuracy: 98.68% (Tested on 70+ challenging samples).
  • Speed: Real-time processing using standard CPU.

🚀 Methodology

The algorithm follows a strict processing pipeline:

  1. Preprocessing:

    • Resizing to a fixed height (80px).
    • Blue Strip Masking: Automatically whiting out the left 12% to prevent false positives from the flag.
    • TopHat Transform: Enhances contrast to handle heavy shadows.
    • Otsu Thresholding & Morphology: Converts to binary and cleans salt-and-pepper noise.
  2. Segmentation & Heuristics:

    • Contour Extraction: Identifies potential character blobs.
    • Vertical Projection Profile: Detects valleys in pixel density to split characters that are "stuck" together.
    • Fragment Merging: Recombines broken character parts (e.g., the letter 'گ' or '5').
    • Geometric Filtering: Filters based on Aspect Ratio and Height relative to the plate.
  3. Final Selection:

    • Median-Y Alignment: Calculates the central line of the plate and discards noise (like frames or screws) that falls too far from the center.
    • Sorting: Returns the top 8 candidates sorted from left to right.

📂 Project Structure

├── inputs/           # Directory containing raw license plate images
├── output/           # Resulting images with drawn bounding boxes
├── main.py           # Core algorithm implementation
├── requirements.txt  # Python dependencies
├── report.pdf        # Detailed project report (Persian)
└── README.md         # Project documentation

🛠️ Installation & Usage

  1. Clone the repository:
    git clone https://github.com/mdvr9980/Iranian-License-Plate-Segmentation.git
    cd Iranian-License-Plate-Segmentation

Install dependencies:

pip install -r requirements.txt

Run the script:

Place your images in the inputs folder and run:

python main.py

Check Results:

Processed images with visual bounding boxes will be saved in the output directory. The terminal will display the number of characters found and the accuracy score for each image.

📊 Results

The algorithm successfully handles various edge cases:

Challenge Solution
Shadows TopHat Transformation highlights text regardless of lighting.
Blur/Sticking Vertical Projection finds the optimal cut point between digits.
Blue Bar Pre-masking the left margin eliminates false detections.
Noise Median-Y alignment filters out screws and frame borders.

About

A lightweight, heuristic-based algorithm for segmenting characters in Iranian license plates using OpenCV. Features robust handling of shadows, noise, and connected characters without Deep Learning, achieving 98.68% accuracy.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages