Skip to content

Gray Value Transformer vTool#

The Gray Value Transformer vTool allows you to transform all pixel gray values in an image by inversion or arithmetic operations.

Gray value transformation is a useful preprocessing step to improve or change the gray value range of an image.

The Gray Value Transformer vTool accepts an image via the Image input pin and outputs the transformed image via the Image output pin.

If you use the ROI Creator vTool to specify a region of interest before transformation, the Gray Value Transformer vTool accepts the ROI data via its ROI input pin. In that case, gray value transformation is only performed on the region of interest, resulting in faster processing.

Gray Value Transformer vTool

How It Works#

The Gray Value Transformer vTool offers two common gray value transformations:

  • Inversion: This transformation flips the gray value histogram from left to right, i.e., it inverts the axis of the histogram. This way, bright pixels become darker and vice versa.
    If you select inversion, the arithmetic operations multiplication and addition aren't available.
  • Arithmetic operations:

    • Multiplication: All gray values in the input image are multiplied by a specified factor. For example, you can multiply the image by a factor greater than one to increase the image contrast and make the image brighter. This effect is like an amplification and spreads the histogram.
    • Addition: A specified value is added to all gray values in the input image. Adding a positive value makes the image brighter, especially in the dark regions, whereas adding a negative value darkens the bright regions.

    Multiplication is performed before addition.


    As multiplication and addition change the gray value range of an image, gray value under- or overflows may occur. Gray values that are out of range are automatically set to the highest or lowest gray value of the input image format.

    Example: In an 8-bit image, gray values transformed to negative values will be set to zero and gray values above 255 will be set to 255.

Both methods can help you achieve the following:

  • Produce images that better meet the user's expectations
  • Make interesting image features more prominent
  • Make subsequent image processing easier

Configuring the vTool#

To configure the Gray Value Transformer vTool:

Gray Value Transformer Basic vTool Settings

  1. In the Recipe Management pane in the vTool Settings area, click Open Settings or double-click the vTool.
    The Gray Value Transformer Basic dialog opens.
  2. In the Transformer Operation area, select the desired transformation.
  3. If you have selected Arithmetic operation in step 2, specify the desired Multiplication and Addition values.

You can view the result of the transformation in a pin data view.



Accepts images directly from a Camera vTool or from a vTool that outputs images, e.g., the Image Format Converter vTool.


Accepts a region of interest from the ROI Creator vTool or any other vTool that outputs regions or rectangles. Multiple rectangles or regions are merged internally to form a single region of interest.

  • Data type: RectangleF, RectangleF Array, Region, Region Array



Returns the transformed image. The output image can be used by any vTool accepting images as input.

Supported Pixel Formats#

Depending on the pixel format of the input image, the Gray Value Transformer vTool outputs the following pixel formats:

Input Pixel Format Output Pixel Format
Bayer GR 8 RGB 8 Planar
Bayer GR 16 RGB 16 Planar
Bayer RG 8 RGB 8 Planar
BGRA 8 Packed RGB 8 Planar
BGR 8 Packed RGB 8 Planar
Mono 8 Mono 8
Mono 10 Mono 10
Mono 12 Mono 12
Mono 16 Mono 16
RGB 8 Packed RGB 8 Planar
RGB 16 Packed RGB 16 Planar
RGB 8 Planar RGB 8 Planar
RGB 16 Planar RGB 16 Planar

Typical Predecessors#

Typical Successors#