# 2.6.1.12 imgInvert

## Brief Information

Invert image color

## Command Line Usage

 

1. imgInvert oimg:=<new>; 

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

## 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.

A new image is created. We can see that the color is inverted.
 The original image The output image

## Algorithm

For gray scale image,

O(x, y) = - I (x, y);

For color Image,

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