Skip to main content

Invert

Redistributes pixel intensities to achieve a more uniform histogram distribution.

🖞ïļ Image options and parameters of level method

Level method applies process called "histogram equalization". Histogram equalization is a technique used in image processing to enhance the contrast and visibility of details in an image by redistributing the pixel intensity values. This process can make details in both dark and bright regions of the image more visible.

placeholderplaceholder
Ran in 0.00Ξs (Infinity ops/s)

Kinds of images compatible with algorithm​

Image propertyWhat it meansPossible values
bitDepthnumber of bits per channel[8,16]
componentsnumber of componentsany
alphais alpha channel allowedtrue

Parameters and default values​

  • options

Options​

PropertyRequiredDefault value
channelsno-
gammano1
inputMinno0
inputMaxnoimage.maxValue
outno-
outputMinno0
outputMaxnoimage.maxValue
Implementation

Here's how level filter is implemented in ImageJS:

Input border values selection: The first step is to choose the range of values that the filter must redistribute.

Output border values selection: Then the range of output values must be chosen. It is necessary to understand in what output limits should lie pixels that belong to the input values set.

Calculation of the values: After getting input and output values each pixel is compared with input values and a ratio is calculated by using formula:

value−inputMininputMax−inputMin\dfrac{value - inputMin}{inputMax - inputMin}

where valuevalue is a value of a pixel which is within the input borders. If value is outside of input limits it is equal to maximum input value. From there the formula is reciprocated to compute new output value.

caution

gamma option allows choosing the curve by which points will be connected. It uses Bezier curves to manipulate this shape. The bigger the value, the smoother the connection is.

Setting the values: After calculating it, the filter replaces the original pixel value with this levelled value. This process is repeated for every pixel in the image, as the window moves over the entire image.