Skip to main content

Invert

Reverses the colors of an image, transforming dark areas into light and vice versa.

🖞ïļ Image options and parameters of invert method
🎭 Mask options and parameters of invert method

Invert filter is an image processing technique used to reverse the color values of an image, creating a negative or "inverted" version of the original. In this process, the darkest areas become the lightest, and the lightest areas become the darkest, while the midtones are adjusted accordingly. The invert filter is a simple but effective way to create visual contrast and produce interesting effects.

Applying invert filter on Images​

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

Parameters and default values​

Kinds of images compatible with algorithm​

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

Parameters and options for Images and Masks are the same.

  • options

Options​

PropertyRequiredDefault value
outno-
info

The method is also available for Masks.

Implementation

Here's how invert filter is implemented in ImageJS:

Pixel Transformation: For each pixel in the image, the inversion filter transforms its color intensity value. The new intensity value is calculated using the formula:

NewIntensity=MaxIntensity−OriginalIntensityNew Intensity = Max Intensity - Original Intensity

Where MaxIntensityMax Intensity is the maximum possible intensity value for the color channel.

warning

ImageJS uses components to calculate each pixel value and leaves alpha channel unchanged.