2.6.1.4 imgColorlevel

Menu Information

Image: Adjustments: Color Level

Brief Information

Apply user-defined color levels to image

Command Line Usage

1. imgColorlevel c:=green w:=90 b:=20 g:=80;

2. imgColorlevel c:=red w:=80 b:=20 oimg:=<new>;

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 image to manipulate. By default, the input image is the active image.

Channel c

Input

int

master

Specifies the color channel to apply color leveling.


Option list

  • M:Master
    The master channel
  • R:Red
    The red channel
  • G:Green
    The green channel
  • blue:Blue
    The blue channel
HiClip(%) w

Input

double

100

Specifies the percentage of highlight levels, which will be remapped to max level during color leveling.

LoClip(%) b

Input

double

0

Specifies the percentage of shadow levels, which will be remapped to min level during color leveling.

Gamma g

Input

double

1

Specifies the gamma value used to remap the mid-tone values.

Output Image oimg

Output

Image

<input>

Specifies the output image. See the syntax here.

Level Report cl

Output

ReportData

[<new>]<new>!

Specifies the leveling report.


Description

The imgColorlevel function applies color leveling to an image, which can alter the highlights, midtones and shadows of a color channel and thus can be used to enhance the color of the image. For example, if the input image has too few highlights in its green channel (you can judge that from the histogram or directly from the input image), you can set the HiClip(%) variable to a number less than 100 to boost the highlights.

Examples

In this example, the input image has too few highlights in the green channel. We can tell this from the image view of the input image and the histogram of its green channel. To boost the green highlights, we use the imgColorlevel X-Function.

ImgColorlevel help English files image002.jpg

ImgColorlevel help English files image004.gif

Original image
Histogram of green channel in original image


Before using the X-function, we first decide a proper HiClip(%) to use. The histogram shows that there are very few pixels whose green levels are not less than 224. So we decide to remap the color levels that are not less than 224 to the max level (255). We compute the value of HiClip(%) as follows:

ImgColorlevel help English files image006.gif

In other words, we decide to set HiClip(%) to 88.

Then, we can use the imgColorlevel X-Function as follows:

  1. Make the input image active. Then, we choose Image: Adjustment: Color Level from the Origin menu. This opens the dialog of the X-Function.
  2. Select Green with the Channel drop-down list. Enter 88 in the HiClip(%) box. Click OK to close the dialog. Then the input image is replaced by the output image.

We can see there are more green highlights now.

ImgColorlevel help English files image008.jpg

ImgColorlevel help English files image010.gif

Output image
Histogram of green channel in output image


The leveling report:

ImgColorlevel help English files image012.jpg

Algorithm

The computation uses L_ColorLevelBitmap() function from LEADTOOLS Main API. For more information, please refer to the LEADTOOLS Main API Help file, Version 14 and read the following topic: L_ColorLevelBitmap.

References

LEADTOOLS Main API Help file, Version 14

Related X-Functions

imgLevel, imgAutoLevel