OriginLab Corporation - Scientific Graphing and Data Analysis Software - 2D graphs, 3D graphs, Contour Plots, Statistical Charts, Data Exploration, Statistics, Curve Fitting, Signal Processing, and Peak Analysis

imgC2gray

Contents

Menu Information

Color to Gray

Brief Information

Convert to a grayscale image

Command Line Usage

1.imgc2gray gray:=16;

2.imgc2gray img:=mat(1) oimg:=mat(2);

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
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.

Gray Scale gray

Input

int

8

Specifies the number of bits per screen pixel for the output grayscale image

Description

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.

Examples

In this example, we use the imgC2gray function to convert the input color image into an 8-bit grayscale image:

  1. When the input image is active, select Image: Conversion: Color to Gray. This opens the dialog of the X-Function.
  2. In the X-Function dialog, change the settings as the screenshot below and click OK to close the dialog.
    Image:imgC2gray_help_English_files_image002.jpg
    A new grayscale image is created as a result.
Image:imgC2gray_help_English_files_image004.jpg
Image:imgC2gray_help_English_files_image006.jpg
The original image
The output image


For more examples, please refer to XF Script Dialog (press F11).

Algorithm

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.

References

LEADTOOLS Main API Help file, Version 14

Related X-Functions

imgBinary, imgAutoBinary, imgDynamicBinary, imgThreshold