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â
Parameters and default valuesâ
Kinds of images compatible with algorithmâ
Image property | What it means | Possible values |
---|---|---|
bitDepth | number of bits per channel | [1,8,16] |
components | number of components | any |
alpha | is alpha channel allowed | true |
Parameters and options for Images and Masks are the same.
options
Optionsâ
Property | Required | Default value |
---|---|---|
out | no | - |
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:
Where is the maximum possible intensity value for the color channel.
ImageJS uses components to calculate each pixel value and leaves alpha channel unchanged.