ImageGear for C and C++ on Windows v19.0
IG_FX_chroma_key

This function blends two images, inserting the pixel values from hIGearBkGrnd wherever the pixel in hIGearFrGrnd is in the specified hue range.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_FX_chroma_key (
        HIGEAR hIGearFrGrnd, 
        LPAT_RECT lpRect, 
        HIGEAR hIGearBkGrnd, 
        const DOUBLE dblHueCenter, 
        const DOUBLE dblHueRange, 
        const UINT nSmooth, 
        const UINT nThreshold 
);

Arguments:

Name Type Description
hIGearFrGrnd HIGEAR HIGEAR handle of image to modify where the specified hue is found.
lpRect LPAT_RECT Far pointer to an AT_RECT structure specifying the rectangular portion of the image to be processed. Use 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.
hIGearBkGrnd HIGEAR HIGEAR handle of an image to insert from on hue match.
dblHueCenter const DOUBLE The angle in degrees (in the standard Color Wheel) of the hue to match. 0.0 - 360.0 (360 == 0).
dblHueRange const DOUBLE The range on which to allow (in degrees) either side. 0.0 - 360.0.
nSmooth const UINT An integer from 0 to 25 specifying how much to smooth the transition. 0 gives the sharpest edge.
nThreshold const UINT Intensity below which to ignore the hue, and fail the match (0 - 255).

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++, except:
Indexed RGB – 1 bpp
Grayscale – 1 bpp

Sample:

FlashPix

Example:

 
Copy Code
HIGEAR hiGear, /* HIGEAR handle of image to blend into  */
hIGear Bkgrnd; /* HIGEAR handle of image to blend in  */
AT_PIXEL pixelvalue[3]; /* 3 bytes for return of an RGB pixel value */
DOUBLE Hue;     /* Hue angle that will be returned */
/* Retrieve the RGB value of the pixel at (10,20) in the HIGEAR image */
nErrcount = IG_DIB_pixel_get (hIGear, 10, 20, &pixelvalue[0]);
/* Pass the RGB pixel value to IG_IP_RGB_to_hue to convert to hue angle  */
nErrcount = IG_IP_RGB_to_hue (&pixelvalue[0], &Hue);
/* Pass newly calculated hue angle to chroma_key to combine images   */
IG_FX_chroma_key ( hIGear, NULL, hIGearBkgrnd, Hue, 10.0, 0, 20 );

Remarks:

You can control the smoothness of the transitions using argument nSmooth, and you can prevent the hue of dark pixels from being considered, using nThreshold. To determine the proper hue center and hue range, you may want to use the IG_DIB_pixel_get() and IG_IP_RGB_to_hue() functions.

See also IG_IP_blend_with_LUT(), IG_DIB_pixel_get() and IG_IP_RGB_to_hue() functions.

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. 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().

See the descriptions of IG_IP_NR_ROI_mask_associate and IG_IP_NR_ROI_to_HIGEAR_mask for more details. The "background image" must have the same height, width, and bit depth as the "foreground image."

The hue is not an 8-bit HSI. HSI is the name of the color space.

 

 


©2017. Accusoft Corporation. All Rights Reserved.

Send Feedback