Coder Social home page Coder Social logo

owaisk4 / parallel_image_enhancement Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 13.44 MB

Parallelized image enhancement code written in C++ and OpenMP. Uses ImageMagick to convert jpg/png images to ppm format and then applies image enhancement techniques like Gaussian Filtering and Histogram Equalization.

License: MIT License

C++ 97.66% Python 2.34%

parallel_image_enhancement's Introduction

Parallel Image Enhancement

Table of Contents
  1. About The Project
  2. Introduction
  3. Algorithm
  4. Examples
  5. Benchmarks
  6. Getting Started
  7. Acknowledgements
  8. License
  9. Contact

About The Project

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.

Built With

  • C++20
  • OpenMP 5.0
  • ImageMagick

(back to top)

Introduction

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.

(back to top)

Algorithm

After preprocessing the input images to PPM, the algorithm works as follows, for each image in the target directory:

  1. Create a PPM Object by reading the image file in memory.
  2. Convert the RGB pixels of the PPM object into HSV colorspace values (for easier manipulation of lightness values).
  3. Create a blurred image from the original using a 5x5 Gaussian filter.
  4. Create an image mask of the original image using the blurred image.
  5. Sharpen the image by subtracting the lightness values of the image mask from the original image. This gives us the locally enhanced image.
  6. 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.
  7. Convert all 3 enhanced images from HSV colorspace back to RGB pixels in separate PPM objects.
  8. Write the resulting 3 PPM objects to separate output files.
  9. Convert the newly created PPM files into JPG using the ImageMagick utility.
RGB Colorspace HSV Colorspace
RGB HSV

(back to top)

Examples

Original image Enhanced image
Dark Image Dark Image Enhanced
Original image Enhanced image
Jase Bloor Jase Bloor Enhanced
Original image Enhanced image
X-ray Shoulder X-ray Shoulder Enhanced

(back to top)

Benchmarks

Sample 1 (84.9 MB) Sample 2 (246.8 MB)
Threads Time (in seconds)
1 17.78424
2 4.24503
3 3.85207
4 4.87121
5 4.18472
6 4.03638
7 4.59338
8 4.20575
Threads Time (in seconds)
1 29.1509
2 11.8906
3 9.9716
4 13.3801
5 12.0371
6 11.7283
7 12.698
8 12.1187
Graph 1 Graph 2
Graph 1 Graph 2

(back to top)

Getting Started

To get a local copy up and running follow these simple example steps.

Prerequisites

  • 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

Installation and Usage

  1. Clone the repository to your local machine.

    git clone https://github.com/OwaisK4/Parallel_Image_Enhancement
  2. 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
  3. 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
  4. Change the dir_path inside the testing_ppm.cpp file and compile it using g++.

    g++ testing_ppm.cpp -fopenmp -o testing_ppm
  5. 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

(back to top)

Acknowledgements

  1. Hangün, Batuhan and Bayar, Salih, An Openmp-Based Parallel Implementation of Image Enhancement Technique for Dark Images

  2. Chernov, Vladimir & Alander, Jarmo & Bochko, Vladimir. (2015). Integer-based accurate conversion between RGB and HSV color spaces. Computers & Electrical Engineering.

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Owais Ali Khan - @OwaisK484 - [email protected]

Linkedin - Profile

Project Link: Parallel Image Enhancement

(back to top)

parallel_image_enhancement's People

Contributors

owaisk4 avatar

Stargazers

Steven Short avatar Umar Siddiqui avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.