This repository contains Python and Cython implementations of the Sobel edge detection algorithm for image processing. The codes and files provided are:
- sobel_pycode.py: Python implementation of the Sobel edge detection algorithm using NumPy.
- sobel_cycode.pyx: Cython implementation of the Sobel edge detection algorithm with C optimizations.
- setup.py: Python script to compile the Cython code into C Extension Module.
- test.py: Python script to execute and compare the Python and Cython implementations.
- img4.png: Sample image for testing the edge detection algorithm.
To set up the environment and install necessary dependencies:
- Create a new Anaconda environment:
conda create -n image_processing_env python=3.
- Activate the environment:
conda activate image_processing_env
- Install required packages:
conda install numpy matplotlib imageio cython
- Compilation Compile the Cython code (sobel_cycode.pyx) into C Extension Module (run the Anaconda Prompt in the same directory):
python setup.py build_ext --inplace
- Generate HTML annotations for the Cython code
cython -a sobel_cycode.pyx
- Execution Execute the main Python script (test.py) to compare the execution times of the Python and Cython implementations:
python test.py
The execution times of the Python and Cython implementations of the Sobel edge detection algorithm will be displayed, along with visualizations of the original and processed images. See the ouput sample below:
iii. Final Output