GPU Adaptive Thresholding using CUDA

CUDA implementation of adaptive thresholding for document binarization. Achieved up to 193× speedup over a CPU implementation while maintaining identical output quality.

Overview

Adaptive thresholding is a document image processing technique used to convert grayscale images into binary images. Unlike global thresholding, which applies a single threshold to the entire image, adaptive thresholding computes a local threshold for every pixel based on its surrounding neighborhood.

This makes it particularly effective for scanned documents containing shadows, uneven illumination, faded text, and noisy backgrounds.

Results

Input Image
Original Input Image
Thresholded Output
Thresholded Output

Performance Benchmark

Image Size Window Size CPU Time (ms) GPU Time (ms) Speedup
700 × 1145 7 109.63 1.68 65×
700 × 1145 15 330.52 1.70 193×

Processing Pipeline

Input Image (.avif)
        ↓
Convert to Grayscale PGM
        ↓
Adaptive Thresholding
        ↓
CPU Implementation
        ↓
GPU CUDA Implementation
        ↓
Performance Comparison
        ↓
Binary Output Image

Implementation Notes

Technologies

Repository

Source code, build instructions, and implementation details are available on GitHub:

View Repository →