2.6.1.2 imgBalance
Menu Information
Image: Adjustments: Balance
Brief Information
Balance image color
Command Line Usage
1. imgBalance c2r:=10 m2g:=40 y2b:=30 oimg:=<new>;
2. imgbalance c2r:=10 m2g:=40 y2b:=30 img:=[Mbook1]Msheet1!Mat(1);
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
|
Cyan to Red
|
c2r
|
Input
int
|
0
|
Specifies how to change of color levels in red channel. This value should be between -100 to 100. A positive value means more red tints will be added, while a negative values means more cyan tints will be added.
|
Magenta to Green
|
m2g
|
Input
int
|
0
|
Specifies how to change of color levels in green channel. This value should be between -100 to 100. A positive value means more green tints will be added, while a negative values means more magenta tints will be added.
|
Yellow to Blue
|
y2b
|
Input
int
|
0
|
Specifies how to change of color levels in blue channel. This value should be between -100 to 100. A positive value means more blue tints will be added, while a negative values means more yellow tints will be added.
|
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 imgBalnce function alters the color levels within the input image. You can use it to apply color balancing. For example, if the input image has too many red tints, you can use this function to reduce the red tints so as to improve its coloring.
Examples
This example uses pe_mkdir and Use pe_cd X-Functions to create folder and go to the created folder.
Then it imports an image file and uses imgBalance, imgContrast, imgBrightness X-Functions to adjust the image.
pe_mkdir Adjustments path:=aa$; //Create a new folder called Adjustments under current folder in the Project Explorer
pe_cd aa$; //go to Adjustments subfolder.
window -t m;//Create a matrix book
fname$ = System.path.program$ +"samples\Image Processing and Analysis\white camellia.jpg";
impimage;//Import image file specified in fname$ into matrix
window -r %h Original;// Rename the matrix book short name as Original
window -d; //Duplicate the matrix book
window -r %h Modified; //Rename the duplicated matrix book short name as Modified
imgBalance c2r:=-7 m2g:=5; //White balance
imgContrast a:=-22; //Decrease contrast by 22 percent
imgBrightness a:=10; //Increase brightness by 10 percent
window -s T; //Tile the windows horizontally
Algorithm
For each pixel in the input image, the red, green, blue value is modified. The modification is controlled by to the variables: Cyan to Red, Magenta to Green and Yellow to Blue.
For more information, please refer to the LEADTOOLS Main API Help file, Version 14 and read the L_BalanceColors topic.
References
LEADTOOLS Main API Help file, Version 14
Related X-Functions
imgColorlevel
|