# 2.6.1.14 imgSaturation

## Command Line Usage

 

1. imgSaturation a:=30; 

2. imgSaturation a:=-30 img:=mat(1) oimg:=mat(2); 

## Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description

Input

double

0

Specifies the percentage of saturation change. The value varies between [-100, 100]. A negative value reduces the saturation, while a positive one increases it.

Input Matrix img

Input

Image

<active>

Specifies the 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 saturation refers to the intensity of a certain color. The imgSaturation function can be used to adjust the saturation of an image, making the color darker or lighter. In this X-Function, the change of saturation based on the image's original saturation level is relative. This means that the input value of the Adjust Saturation variable is the percentage to change. The change can be either negative or positive. A negative value reduces the saturation, making the color lighter; while a positive one increases the saturation, making the color darker.

## Examples

In this example, we use the imgSaturation function to make the colors in the input image lighter:

1. When the input image is active, select Image: Adjustments: Saturation. 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 lighter.
 The original image The output image

## Algorithm

The value of the Saturation level is changed by the following formula:

where is the output saturation, is the input saturation and change is specified by the Adjust Saturation variable.

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

## References

LEADTOOLS Main API Help file, Version 14