Skip to content

Latest commit

Β 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Canny Edge Detector Implementation πŸ”

A complete from-scratch implementation of the Canny edge detection algorithm for image processing applications.

License Python NumPy

Features ✨

  • Complete Canny Algorithm: Full implementation of all five stages (Gaussian smoothing, gradient calculation, non-maximum suppression, double thresholding, hysteresis tracking)
  • Configurable Parameters: Adjustable sigma, kernel size, and threshold values for different use cases
  • Class-Based Design: Clean, reusable object-oriented implementation
  • Image Utilities: Built-in functions for loading, converting RGB to grayscale, and visualization
  • Educational Examples: Comprehensive Jupyter notebooks demonstrating the algorithm pipeline
  • Image Alignment Applications: Extended use cases for practical image processing tasks

Tech Stack / Built With πŸ› οΈ

Python NumPy SciPy Matplotlib

  • Python 3.7+: Core programming language
  • NumPy: Numerical computations and array operations
  • SciPy: Scientific computing and image processing functions
  • Matplotlib: Image visualization and plotting
  • Jupyter: Interactive development and demonstration

Prerequisites

  • Python 3.7 or higher
  • pip package manager

Installation πŸ“₯

# Clone the repository
git clone https://gitlab.com/user4302_Projects/coding/python/university/iit/canny-edge-detector.git
cd canny-edge-detector

# Install required packages
pip install numpy scipy matplotlib jupyter

Usage / Quick Start ⚑

Basic Edge Detection

from cannyedgedetector import CannyEdgeDetector
from utils import utils

# Load and preprocess images
images = utils.load_data('path/to/images')

# Initialize detector with custom parameters
detector = CannyEdgeDetector(
    images, 
    sigma=1.4, 
    kernel_size=5, 
    low_threshold=0.09, 
    high_threshold=0.17
)

# Detect edges
edge_images = detector.detect()

# Visualize results
utils.visualize(edge_images, 'gray')

Advanced Configuration

# Custom detector configuration
detector = CannyEdgeDetector(
    images,
    sigma=1.0,                    # Gaussian smoothing parameter
    kernel_size=5,                # Size of Gaussian kernel
    weak_pixel=75,               # Intensity for weak edges
    strong_pixel=255,            # Intensity for strong edges
    low_threshold=0.05,          # Lower threshold ratio
    high_threshold=0.15          # Higher threshold ratio
)

Project Structure πŸ“‚

canny-edge-detector/
β”œβ”€β”€ cannyedgedetector.py          # Main CannyEdgeDetector class
β”œβ”€β”€ utils/
β”‚   └── utils.py                  # Utility functions (load, visualize, rgb2gray)
β”œβ”€β”€ Canny_Edge_Detector.ipynb     # Main demonstration notebook
β”œβ”€β”€ image_alignment_task.ipynb     # Extended image processing examples
β”œβ”€β”€ face_images/                  # Sample images directory
β”œβ”€β”€ README.md                     # This file
└── .git/                         # Git repository

Configuration πŸ”§

The CannyEdgeDetector class accepts the following parameters:

  • sigma (float, default=1): Standard deviation for Gaussian kernel
  • kernel_size (int, default=5): Size of the Gaussian kernel (must be odd)
  • weak_pixel (int, default=75): Intensity value for weak edges
  • strong_pixel (int, default=255): Intensity value for strong edges
  • low_threshold (float, default=0.05): Lower threshold ratio (0-1)
  • high_threshold (float, default=0.15): Higher threshold ratio (0-1)

Development / Running Locally πŸ—οΈ

# Start Jupyter notebook for interactive development
jupyter notebook

# Run specific notebooks
jupyter nbconvert --to notebook --execute Canny_Edge_Detector.ipynb
jupyter nbconvert --to notebook --execute image_alignment_task.ipynb

Testing πŸ§ͺ

The project includes demonstration notebooks that serve as functional tests:

# Run the main demonstration
jupyter nbconvert --to notebook --execute Canny_Edge_Detector.ipynb --inplace

# Run image alignment examples
jupyter nbconvert --to notebook --execute image_alignment_task.ipynb --inplace

Building for Production 🏭

This is a pure Python library with no build steps required. Simply import the modules:

import cannyedgedetector
from utils import utils

Deployment πŸš€

The library can be deployed as:

  1. Python Package: Install via pip from local directory
  2. Docker Container: Containerize with Python base image
  3. Cloud Function: Deploy as serverless function for image processing
  4. Web Service: Wrap in Flask/FastAPI for HTTP API

Contributing 🀝

We welcome contributions! Please follow these guidelines:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Merge Request

Important: For any questions, bug reports, feature requests, or security concerns, please open an issue on GitLab: https://gitlab.com/user4302_Projects/coding/python/university/iit/canny-edge-detector/-/issues

License πŸ“„

This project is licensed under the MIT License - see the LICENSE file for details.

License

Support & Contact πŸ‘‹

For any questions, bug reports, feature requests, or security concerns, please open an issue on GitLab: https://gitlab.com/user4302_Projects/coding/python/university/iit/canny-edge-detector/-/issues

No email or direct messaging support is available.

Acknowledgments πŸ™

  • John Canny for the original edge detection algorithm (1986)
  • SciPy and NumPy communities for excellent numerical computing tools
  • Computer vision researchers and practitioners who continue to advance edge detection techniques

About

Mirror of GitLab project Canny-Edge-Detector https://gitlab.com/user4302_Projects/coding/python/university/iit/canny-edge-detector

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages