Table of Contents
Parallelized image enhancement code written in C++ and OpenMP 5.0. Uses ImageMagick to convert jpg/png images to PPM format and then applies image enhancement techniques including Gaussian filtering and histogram equalization in order to sharpen low-quality images and increase contrast for dark images.
- C++20
- OpenMP 5.0
- ImageMagick
The fields of medical, UAV, and satellite imagery often generate images that are quite confusing and unintuitive to humans. Image enhancement is a frequently used technique to improve the visual quality and contrast of such images. In order to acquire digital images with good contrast, we balance the number of pixels with darker and brighter intensity in a local and/or global manner. Besides image quality, there is another problem with image processing applications, such as image size. As the image size gets bigger, it takes increasingly more time for computers to complete the given task. Parallel computing is a method that exploits several processing units on the same system to expedite the computation of individual pixels using data parallelism. One final problem is that most image formats, i.e. jpg, png, jpeg, etc, are compressed to some extent. In order to manipulate RGB pixels, we first convert all input images into the Portable PixMap (PPM) format, specifically P3.
After preprocessing the input images to PPM, the algorithm works as follows, for each image in the target directory:
- Create a PPM Object by reading the image file in memory.
- Convert the RGB pixels of the PPM object into HSV colorspace values (for easier manipulation of lightness values).
- Create a blurred image from the original using a 5x5 Gaussian filter.
- Create an image mask of the original image using the blurred image.
- Sharpen the image by subtracting the lightness values of the image mask from the original image. This gives us the locally enhanced image.
- Send the original and the locally enhanced image to the Global Enhancement subroutine, which uses Histogram Equalization for enhancement. This returns the globally enhanced and the totally enhanced image.
- Convert all 3 enhanced images from HSV colorspace back to RGB pixels in separate PPM objects.
- Write the resulting 3 PPM objects to separate output files.
- Convert the newly created PPM files into JPG using the ImageMagick utility.
RGB Colorspace | HSV Colorspace |
---|---|
![]() |
![]() |
Original image | Enhanced image |
---|---|
![]() |
![]() |
Original image | Enhanced image |
---|---|
![]() |
![]() |
Original image | Enhanced image |
---|---|
![]() |
![]() |
Sample 1 (84.9 MB) | Sample 2 (246.8 MB) | ||||||||||||||||||||||||||||||||||||
|
|
Graph 1 | Graph 2 |
---|---|
![]() |
![]() |
To get a local copy up and running follow these simple example steps.
-
Any C++20 compiler (default g++)
- For Debian-based distros
apt install g++
- For RPM-based distros
yum install gcc-c++
-
ImageMagick
apt install imagemagick
-
Clone the repository to your local machine.
git clone https://github.com/OwaisK4/Parallel_Image_Enhancement
-
Change the dir_path inside the openmp_convert_images.cpp file and compile it using g++ (Make sure to pass the -fopenmp flag to link the OpenMP libraries).
g++ openmp_convert_images.cpp -fopenmp -o openmp_convert_images
-
Run the resulting executable and select the "Convert to ppm" option to convert all images inside target dir_path to PPM3 format.
./openmp_convert_images
-
Change the dir_path inside the testing_ppm.cpp file and compile it using g++.
g++ testing_ppm.cpp -fopenmp -o testing_ppm
-
Run the resulting executable, with no. of threads passed as argument, and wait for its completion. After it completes, each ppm file will have 3 matching enhanced images inside the dir_path folder.
./testing_ppm 8
-
Hangün, Batuhan and Bayar, Salih, An Openmp-Based Parallel Implementation of Image Enhancement Technique for Dark Images
-
Chernov, Vladimir & Alander, Jarmo & Bochko, Vladimir. (2015). Integer-based accurate conversion between RGB and HSV color spaces. Computers & Electrical Engineering.
Distributed under the MIT License. See LICENSE.txt
for more information.
Owais Ali Khan - @OwaisK484 - [email protected]
Linkedin - Profile
Project Link: Parallel Image Enhancement