2.6.1.12 imgInvert

Menu Information

Image: Adjustments: Invert

Brief Information

Invert image color

Command Line Usage

1. imgInvert oimg:=<new>;

2. imgInvert img:=mat(1) oimg:=mat(2);

X-Function Execution Options

Please refer to the page for additional option switches when accessing the x-function from script

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Input Matrix img

Input

Image

<active>

Specifies the source image to be manipulated. The default input is the active image.

Output Image oimg

Output

Image

<input>

Specifies the output image. By default, the output image is the same as the input image.

See the syntax here.

Description

The imgInvert function inverts the colors in the specified bitmap, making it like a photographic negative. This function can also be used to invert the color of a 1-bit image, making the black white and the white black.

Examples

In this example, we use the imgInvert function to invert the color of the input image:

  1. When the input image is active, select Image: Adjustments: Invert. This opens the dialog of the X-Function.
  2. In the X-Function dialog, change the settings as the screenshot below and click OK to close the dialog.
    ImgInvert help English files image002.jpg
    A new image is created. We can see that the color is inverted.
ImgInvert help English files image004.jpg
ImgInvert help English files image006.jpg
The original image
The output image


Algorithm

For gray scale image,

O(x, y) = ImgInvert help English files image008.gif- I (x, y);

For color Image,

ImgInvert help English files image010.gif
ImgInvert help English files image012.gif
ImgInvert help English files image014.gif

where O(x, y) is the output pixel value, I(x, y) is the input pixel value, and Bits is Bits Per Pixel.

The computation uses L_InvertBitmap() function from LEADTOOLS Main API. Please refer to the LEADTOOLS Main API Help file, Version 14 and read the L_InvertBitmap topic.

References

LEADTOOLS Main API Help file, Version 14

Related X-Functions

imgHue