- Overview
- Repository Structure
- Prerequisites
- Installation
- Usage
- Cuda Kernels
- Performance
- Credits
- License
- Author
This project implements histogram equalization for grayscale images using CUDA. It leverages GPU parallel processing to achieve high performance, particularly for large datasets or computationally intensive tasks. The algorithm incorporates different parallel prefix sum (scan) algorithms:
- Kogge-Stone
- Kogge-Stone with Double Buffer
- Brent-Kung
Histogram equalization is a method in image processing of contrast adjustment using the image's histogram.
Before Histogram Equalization:
Corresponding histogram (red) and cumulative histogram (black):
After Histogram Equalization:
Corresponding histogram (red) and cumulative histogram (black):
.
├── python/
│ └── main.py # Python script for invoking CUDA kernels and managing the workflow
├── c++/
│ ├── main.cu # CUDA source file containing the implementation of kernels
│ └── kernel.cu # CUDA kernel definitions
├── data/ # Directory for input images
└── histequalizer # Script for compiling the project and running benchmarks
- CUDA-capable NVIDIA GPU
- CUDA Toolkit
- OpenCV
- C++ compiler
- CMake
- Python 3.x (for Python interface)
- Python Libraries:
- numpy
- opencv-python
- pycuda
- Clone the repository:
git clone https://github.com/AlessioBugetti/histogram-equalization.git
cd histogram-equalization
- Install Python dependencies:
pip install -r requirements.txt
- Ensure the CUDA environment is set up:
- Install NVIDIA drivers.
- Install the CUDA Toolkit.
- Verify with
nvcc --version
.
./histequalizer build
./histequalizer run
python main.py
CalculateHistogram
: Computes the histogram for the input image.KoggeStoneScan
: Performs parallel prefix sum using the Kogge-Stone algorithm.KoggeStoneScanDoubleBuffer
: Performs parallel prefix sum using the Kogge-Stone algorithm with double buffer.BrentKungScan
: Performs parallel prefix sum using the Brent-Kung algorithm.NormalizeCdf
: Normalizes the CDF for intensity adjustment.EqualizeHistogram
: Applies the equalized histogram to the input image.
The implementation includes benchmarking capabilities that measure:
- Sequential CPU execution time
- CUDA execution time for each scan algorithm.
- Speedup ratios compared to CPU implementation.
- Measurements are averaged over multiple iterations to ensure reliable results.
The images used, placed in the data
folder, were sourced from the official European Space Agency (ESA) website dedicated to the Hubble Space Telescope. All credits to NASA/ESA.
This project is licensed under the GPL-3.0-only License. See the LICENSE
file for more details.
Alessio Bugetti - alessiobugetti98@gmail.com