Skip to content

itsvishwa/sobel-parallel-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Parallel Sobel Edge Detection in C++

Overview

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.


What is the Sobel Operator?

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.

Sobel Operator

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.


Time Complexity of the Sobel Operator

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)

Serial Implementation

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.


Parallelization Using pthreads

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

Parallelization Using OpenMP

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

Build the Program

Compile the project using the provided Makefile:

make

Run he Program

Input Format The program accepts input through the command line:

./sobel <image_path> <mode>

About

A C++ implementation of Sobel edge detection with performance comparison between serial execution, pthreads, and OpenMP parallelization.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors