ImageGear for C and C++ on Linux v20.0 - Updated
IG_IP_contrast_gamma
API Reference Guide > Core Component API Reference > Core Component Functions Reference > Image Processing Functions > IG_IP_contrast_gamma

This function adjusts the contrast of the image using a non-linear gamma method.

Declaration:

 
Copy Code
AT_ERRCOUNT ACCUAPI IG_IP_contrast_gamma(
   HIGEAR hIGear,
   LPAT_RECT lpRect,
   AT_MODE nMethodMode,
   DOUBLE dblGamma
);

Arguments:

Name Type Description
hIGear HIGEAR HIGEAR handle of image.
lpRect LPAT_RECT Specifies a rectangle within the image on which to operate. NULL means the entire image. See Remarks below.
nMethodMode AT_MODE Specifies whether to alter the pixels or the palette. See enumIGContrastModes.
dblGamma DOUBLE Greater than 0.0. Usual range: 0.75 to 3.0.

Return Value:

Returns 0 if successful. Otherwise, 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 hIGear;            // HIGEAR handle of the image
AT_ERRCOUNT nErrcount;    // Count of errs on stack upon ret from func

// Load image file "picture.bmp" from working directory
nErrcount = IG_load_file("picture.bmp", &hIGear);
if(nErrcount == 0)
{
    nErrcount = IG_IP_contrast_gamma(hIGear, NULL, IG_CONTRAST_PIXEL, 2.0);
    // ...
    // Destroy the image
    IG_image_delete(hIGear);
}

Remarks:

Gamma is a non-linear method to adjust the contrast of a image. In this method, the amount a pixel's intensity changes depends on its original intensity. This can be used to make dark regions brighter without over saturating (clipping) the bright regions. Or, conversely, to make light regions darker without under saturating the dark regions. Gamma was originally introduced to compensate for the non-linear nature of the phosphors used in monitors and in the original tube cameras that created images.

While the gamma can be any non-zero positive value, the usual range is 0.75 to 3.0. A gamma value of 1.0 does not alter the image. For typical monitors, a range of 1.8 to 2.2 is usual. Values less than 1.0 cause dark pixels to become brighter. Values greater than 1.0 cause bright regions to become darker.

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 NRA 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.

Is this page helpful?
Yes No
Thanks for your feedback.