ImageGear for C and C++ on Linux v18.8 - Updated
IG_IP_contrast_stretch
API Reference Guide > Core Component API Reference > Core Component Functions Reference > Image Processing Functions > IG_IP_contrast_stretch

This function automatically adjusts the contrast of the image so that at least one pixel is completely black and one pixel is completely white.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_IP_contrast_stretch (
        HIGEAR hIGear, 
        LPAT_RECT lpRect, 
        AT_MODE nMethodMode 
);

Arguments:

Name Type Description
hIGear HIGEAR HIGEAR handle of image.
lpRect LPAT_RECT Far pointer to an AT_RECT struct defining the rectangle within the image that this function is to operate on. If NULL, the entire image will be operated on. 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.
nMethodMode AT_MODE IG_CONTRAST_PIXEL or IG_CONTRAST_PALETTE, telling whether to alter the pixels themselves (the image bitmap) or the palette.

Supported Raster Image Formats:

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

Return Value:

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

Example:

 
Copy Code
HIGEAR hIGear; /* HIGEAR handle of image */ IG_IP_contrast_stretch ( hIGear, NULL,IG_CONTRAST_PIXEL );

Remarks:

This fills the entire range of the pixel intensities. The original pixel intensities are adjusted linearly between the 2 extremes. (If the image already fills the entire range then the image is not altered.)

Images that use the entire range often appear richer and the colors display more vivid.

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.