Understanding Image Contrast Algorithms

Brightness

Contrast

Contrast Stretching / Histogram Stretching

Photo by Giancarlo Corti on Unsplash

Code

Before
After

Histogram Equalization

Credit: Wikipedia

Pseudocode

  1. Iterate through all the pixels in the image
  2. Count the frequency of each intensity value in a dictionary.
  3. Create an empty array of length 256.
  4. Using our dictionary, we’ll fill in this array such that each index stores the probability of that intensity value occurring in the source image. For example, index 5 in the array will represent the probability with which an intensity of 5 appears in the input image.
  5. Create a cumulative distribution function (we’ll go over this in a moment).
  6. Use the cumulative distribution function to transform the original pixel’s value and compute the new pixel value in the output image.
0, 3028
1, 1216
2, 1188
3, 1262
4, 1242
...

Code

Alternatives

Sources

--

--

--

Staff iOS Engineer @ Turo. Previously, Scoop Technologies & Porsche Digital

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

SP4C3 Tensor Processing Unit: a disruptive technology for the crypto market.

ML Basics pt.1 — Linear Regression : Model Representation and Cost Functions

Insect Classifier Model

Machine Learning use case:

ML & AI In Investment Management

Generating Eminem Lyrics with A Computer

Linear regression using pytorch

Hotel recommendation system

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aryaman Sharda

Aryaman Sharda

Staff iOS Engineer @ Turo. Previously, Scoop Technologies & Porsche Digital

More from Medium

Match function: Using C++ pointers, create a method that returns true if and only if its two C…

Exceptions in Python

4 programming languages to play with when you are bored with the usual C, C++, Java, Python stuff

Math: C# vs Python, Which is better?