
Contents |
Color to Gray
Convert to a grayscale image
1.imgc2gray gray:=16;
2.imgc2gray img:=mat(1) oimg:=mat(2);
| Display Name | Variable Name | I/O and Type | Default Value | Description |
|---|---|---|---|---|
| Input Matrix | img |
Input Image | |
Specifies the image to be manipulated. The default input is the active image. |
| Output Image | oimg |
Output Image | |
Specifies the output image. By default, the output image is the same as the input image. See the syntax here. |
| Gray Scale | gray |
Input int | |
Specifies the number of bits per screen pixel for the output grayscale image |
This function allows user to convert a color image to an 8-bit, 12-bit, or 16-bit grayscale image. The output grayscale image is created by calculating a weighted sum of the R, G and B components. The result image has similar levels of contrast to the original color image.
In this example, we use the imgC2gray function to convert the input color image into an 8-bit grayscale image:

For more examples, please refer to XF Script Dialog (press F11).
The computation uses L_GrayScaleBitmap() function from LEADTOOLS Main API. Please refer to the LEADTOOLS Main API Help file, Version 14 and read the L_GrayScaleBitmap topic.
LEADTOOLS Main API Help file, Version 14