Image: Adjustments: Color Replace
Replace color within pre-defined color range
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>;
Please refer to the page for additional option switches when accessing the x-function from script
Display Name |
Variable Name |
I/O and Type |
Default Value |
Description |
---|---|---|---|---|
Input Matrix | img |
Input Image |
|
Specifies the input image to be manipulated. The default input is the active image. |
Output Image | oimg |
Output Image |
|
Specifies the output image. By default, a new image will be created and used as output. See the syntax here. |
Fuzziness | fuzzi |
Input int |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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 |
|
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. |
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.
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 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.
LEADTOOLS Main API Help file, Version 14