Image: Conversion: Color to Gray
Convert to grayscale image
1.imgc2gray gray:=16; 2.imgc2gray img:=mat(1) oimg:=mat(2);
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 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.
//Create a new folder in the Project Explorer pe_mkdir Conversion path:=aa$; pe_cd aa$; //Create a matrix and import a sample image window -t m; path$ = System.path.program$; fname$ = path$ + "samples\Image Processing and Analysis\leaves.jpg"; impimage; window -r %h Original; window -d; //Duplicate the image window -r %h BlueLeave; imgC2gray; //Convert to gray imgUnsharpmask a:=80 r:=30; //Strenghen details window -s T; //Tile the windows horizontally
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