2.6.1.9 imgHistcontrast

Menu Information

Image: Adjustments: Histcontrast

Brief Information

Adjust image contrast using histogram

Command Line Usage

1. imgHistcontrast a:=20;

2. imgHistcontrast a:=-20 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
Adjustment a

Input

double

0

Specifies the amount of contrast change. Valid value range is [-100, +100].

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 overwrites the input image.

See the syntax here.

Description

The imgHistcontrast function increases or decreases the contrast of the input image, using a histogram to determine the median brightness.

This function finds the median brightness of the image, then brightens the pixels with values above the median and darkens the pixels with values below the median. This is more sophisticated (but slower) than the imgContrast function, which uses the middle possible value (128) rather than finding the actual median.

Examples

In this example, we use the imgHistcontrast function to increase the contrast of the input image with the Adjustment as 20:

  1. When the input image is active, select Image: Adjustments: HistContrast. 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.
    ImgHistcontrast help English files image002.jpg
    A new image is created. We can see that the contrast is improved.
ImgHistcontrast help English files image004.jpg
ImgHistcontrast help English files image006.jpg
The original image
The output image


Algorithm

This function finds the median brightness of the image, and then brightens the pixels with values above the median and darkens the pixels with values below the median.

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

References

LEADTOOLS Main API Help file, Version 14

Related X-Functions

imgContrast, imgBrightness