This project demonstrates the use of shared-memory parallel programming techniques to accelerate image processing. It implements the Sobel edge detection operator in C++ and compares the execution time of three approaches: a serial implementation, a pthread-based multithreaded implementation, and an OpenMP-based parallel implementation.
The goal of this project is to utilize image processing fundamentals with parallel computing.
The Sobel operator is a widely used edge detection technique in image processing. It detects edges by computing the intensity gradient of an image in both the horizontal (X) and vertical (Y) directions.
It uses two 3×3 convolution kernels:
- One to detect changes in the horizontal direction
- One to detect changes in the vertical direction
By combining these gradients, the Sobel operator highlights regions of the image where pixel intensity changes sharply, which typically correspond to edges.
For an image of size N × M, the Sobel operator processes each pixel once and applies a constant-size (3×3) convolution kernel.
- Time Complexity:
O(N × M)
The serial version processes the image pixel-by-pixel using nested loops. It serves as a baseline for performance comparison and demonstrates the original computational cost of Sobel edge detection without parallelism.
The pthread-based implementation uses POSIX threads to parallelize the Sobel computation. The image is divided into horizontal slices, and each thread is assigned a fixed range of rows to process.
Key characteristics:
- Shared-memory parallelism
- Static work partitioning
- Each thread processes approximately N / T rows
The OpenMP implementation uses compiler directives to parallelize the outer loop of the Sobel computation.
Key characteristics:
- Compiler-managed thread creation and scheduling
- Static scheduling to evenly distribute rows among threads
- Reduced overhead compared to manual thread management
- Improved cache locality and load balancing
Compile the project using the provided Makefile:
makeInput Format The program accepts input through the command line:
./sobel <image_path> <mode>