2.6.1.5 imgColorReplace
Menu Information
Image: Adjustments: Color Replace
Brief Information
Replace color within pre-defined color range
Command Line Usage
1. imgColorReplace fuzz:=30 r:=255 g:=255 b:=0;
2. imgColorReplace fuzz:=70 adj_b:=-20 adj_s:=-50 adj_h:=-90;
3. imgColorReplace oimg:=<input>;
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 input image to be manipulated. The default input is the active image.
|
Output Image
|
oimg
|
Output
Image
|
<new>
|
Specifies the output image. By default, a new image will be created and used as output.
See the syntax here.
|
Fuzziness
|
fuzzi
|
Input
int
|
50
|
Specifies the Fuzziness value which is used for determining a color range around the specified color. The colors within this range are similar to the specified color and all of them will be replaced. Note that fuzziness value should be an integer between 1 and 100
|
Replace Red
|
r
|
Input
int
|
128
|
Specifies the red component of the color to be replaced. The value should be an integer between 0 and 255
|
Replace Green
|
g
|
Input
int
|
128
|
Specifies the green component of the color to be replaced. The value should be an integer between 0 and 255
|
Replace Blue
|
b
|
Input
int
|
128
|
Specifies the blue component of the color to be replaced. The value should be an integer between 0 and 255
|
Adjust Brightness
|
adj_b
|
Input
int
|
50
|
Specifies the percentage increase/decrease of the brightness for the colors to be replaced. The value should be an integer between -100 and 100. A negative value will cause the brightness to be reduced while a positive value will result in brightness increase.
|
Adjust Saturation
|
adj_s
|
Input
int
|
50
|
Specifies the percentage increase/decrease of the saturation for the colors to be replaced. The value should be an integer between -100 and 100. A negative value will cause the saturation to be reduced while a positive value will result in saturation increase.
|
Adjust Hue
|
adj_h
|
Input
int
|
0
|
Specifies the percentage increase/decrease of the hue for the colors to be replaced. The value should be an integer between -180 and 180. A negative value will cause the hue to be reduced while a positive value will result in hue increase.
|
Description
This function adjusts the brightness, saturation and hue of the specified color to replace it with another color. You can specify the color to be replaced with its RGB components.
You can opt to replace the colors similar to the specified color with the Fuzziness variable. By doing this, you are likely to get a smooth output image with a range of color replaced.
Examples
The following example shows you how to change the color of the input image:
1. Create a new matrix and import red camellia.jpg under \Samples\Image Processing and Analysis folder into it.
2. Select Image: Adjustment: Color Replace... from the menu to open the dialog. Change the settings as shown below and click OK.
|
|
The original image
|
The output image
|
Algorithm
The function first determines the specified color with the input R, G, B values, and then calculates the color range around the specified color. Finally, it applies the adjusted brightness, saturation and hue values to the pixels within the color range.
For more information, please refer to the LEADTOOLS Main API Help file, Version 14 and read the L_ColorReplaceBitmap topic.
References
LEADTOOLS Main API Help file, Version 14
Related X-Functions
imgBrightness, imgSaturation, imgHue
|