ImageGear for C and C++ on Linux v19.10 - Updated
IG_IP_blend_with_LUT
API Reference Guide > Core Component API Reference > Core Component Functions Reference > Image Processing Functions > IG_IP_blend_with_LUT

This function blends two images using Look-Up Tables (LUTs) to determine the strength of each pixel's contribution.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_IP_blend_with_LUT ( 
        HIGEAR hIGearDest, 
        HIGEAR hIGear2, 
        const LPAT_LUT lpLUT_red, 
        const LPAT_LUT lpLUT_green, 
        LPAT_LUT lpLUT_blue, 
        const LPAT_RECT lpRect
);

Arguments:

Name Type Description
hIGearDest HIGEAR HIGEAR handle of the image into which to be blended.
hIGear2 HIGEAR HIGEAR handle of image to blend; must be same size and bit depth.
lpLUT_red const LPAT_LUT Far pointer to Red channel of LUT for RGB images; also used as a single pointer to LUT for grayscale images.
lpLUT_green const LPAT_LUT Far pointer to Green channel of LUT for RGB image; not used for grayscale images.
lpLUT_blue LPAT_LUT Far pointer to Blue channel of LUT of RGB image; not used for grayscale images.
lpRect const LPAT_RECT Rectangular portion of the image to process. Set to NULL for the whole image. Before ImageGear performs this operation, it will check to see if an internal flag has been set to TRUE to make a mask active for this HIGEAR image. If a mask is active, and a valid pointer to a mask can be found, ImageGear will override the settings passed to this structure in favor of the non-rectangular ROI defined by the mask.

Return Value:

Returns the number of ImageGear errors that occurred during this function call.

Supported Raster Image Formats:

All pixel formats supported by ImageGear for C and C++.

Example:

 
Copy Code
HIGEAR hIGearDest    /* HIGEAR handle of image 1, destination */
                hIGear2;   /* HIGEAR handle of image 2    */
AT_LUT LUT_blend[256];   /* The LUT for blend values */
INT pix;            /* Loop index, = pixel value  */
AT_ERRCOUNT nErrcount;     /* Returned count of errors   */
for ( pix = 0;  pix < 256;  pix++ )
        { LUTblend[pix] =  25; }    /* set Look-Up Table   */
for (pix = 10; pix < 100; pix++)
        { LUTblend[pix] = 75; }
nErrcount =  IG_IP_blend_with_LUT ( hIGearDest, hIGear2, (LPAT_LUT)&LUT_blend, 
        (LPAT_LUT)&LUT_blend, (LPAT_LUT)&LUT_blend, NULL );

Remarks:

The pixel values from hIGearDest are used as the indexes into the LUTs. Both hIGear2 and hIGearDest must be the same bit depth and dimensions. The image in hIGearDest is destroyed and is replaced with the resulting blend.

For RGB images, each channel (R, G, or B) of the hIGearDest image is processed through its own LUT.

For indexed and grayscale images, the lpLUT_red is used and the other two are ignored (you can pass in NULL for these).

Images that have other colorspaces, such as CMYK or LAB, are converted into RGB for processing internally, and then converted back to their original colorspace. The function works on these images as if they had RGB colorspace.

The function does not process Alpha and Extra channels, if they are present in the image.

Each LUT that is to be used must point to a LUT that has at least enough entries to process the images being passed in. For images having up to 8 bits per channel, LUTs must contain 256 bytes. For images having up to 16 bits per channel, LUT must contain 65536 bytes.

Each entry into the LUT determines the percentage of the blend on a pixel-by-pixel basis. Pixel values of the hIGearDest image are used as indexes into the array. The LUTs should be initialized with values from 0 to 100, where:

For grayscale images, the value of each pixel in hIGearDest is used as the index into the LUT. For RGB images, it is the intensity, calculated as (R+G+B)/3 that is used. For other colorspaces, pixels are converted to RGB and then intensity is calculated.

This function, like other ImageGear Image Processing and Clipboard API calls, takes an AT_RECT structure as an argument, so that you can process a rectangular sub-region of an image. (See above.) However, before ImageGear performs the operation specified by this function, it will check to see if an internal flag has been set to TRUE, indicating that a mask HIGEAR should be used with the image. If the flag is set to TRUE, and a valid pointer to a mask image has been assigned, ImageGear will override the settings passed to the AT_RECT structure and use the non-rectangular ROI defined by the mask HIGEAR. To create a non-rectangular region of interest, call IG_IP_NR_ROI_to_HIGEAR_mask().

Please see the descriptions of IG_IP_NR_ROI_mask_associate() and IG_IP_NR_ROI_to_HIGEAR_mask() functions for more details.