is_image_grayscale

 

Description

check if Image Matrix Object is a gray scale image


check if Image is a gray scale image

Syntax

bool is_image_grayscale( MatrixObject & mo )

bool is_image_grayscale( BITMAPHANDLE * pLBmp )

Parameters

mo
[modify] Target matrix object(Image) to be check.

pLBmp
[modify] Target Image Bitmap Handler

Return

if mo contains an grayscale image, return true


if pLBmp point to an grayscale image, return true

Examples

Prior to compilation, load matdata_utils.c to the workspace by executing the following LabTalk command:

Run.LoadOC("Originlab\matdata_utils.c", 16);

To retain matdata_utils.c in the workspace for successive sessions, drag and drop the file from the Temporary folder to the System folder.

EX1

#include <..\originlab\matdata_utils.h>
//this example assumes that there is already an image in the active matrixsheet in MBook1 matrixbook
void is_image_grayscale_ex1()
{
    MatrixObject        mobj;
    if (!mobj.Attach("MBook1"))
    {
        out_str("Attachment failed!");
    }
    bool nRet = is_image_grayscale(mobj);
    if (nRet)
    {
        out_str("This is a grayscale image");
    }
    else
    {
        out_str("This is not a grayscale image");
    }
}


EX2

#include <..\originlab\matdata_utils.h>
#include <image_utils.h>
//this example assumes that there is already an image in the active matrixsheet in MBook1 matrixbook
void is_image_grayscale_ex2()
{
    MatrixObject        mobj;
    if (!mobj.Attach("MBook1"))
    {
        out_str("Attachment failed!");
    }
    
    Image img(mobj);
    if(!img.IsValid())
        return;
    BITMAPHANDLE* pLBmp = img.GetLBmp();
    
    bool nRet = is_image_grayscale(mobj);    
    if (nRet)
    {
        out_str("This is a grayscale image");
    }
    else
    {
        out_str("This is not a grayscale image");
    }
}

Remark

See Also

image_to_gray

header to Included

matdata_utils.h

Reference