ImageGear for C and C++ on Linux v18.8 - Updated
Contrast Alteration
User Guide > How to Work with... > Image Processing and Cleanup > Contrast Alteration

ImageGear's contrast alteration functions operate by altering the range of pixel intensities that occur in your image, or by redistributing the occurrence frequency of the pixel intensities. There are five IG_IP_contrast_...() functions, which operate as follows:

IG_IP_contrast_adjust() Adjusts the contrast of the image by stretching or compressing the range of intensities that occur. Also adjusts brightness by adding or subtracting the specified constant to each intensity value.
IG_IP_contrast_stretch() Adjusts the contrast of the image by stretching the range of intensities that occur, such that the least intense pixel becomes full black, and the most intense becomes full white.
IG_IP_contrast_equalize() Adjusts the contrast of the image by stretching or compressing sub-ranges of intensities that occur, so that there are an approximately equal number of pixels in each sub-range. This can bring out subtle changes in contrast when contrast is poor in the original, such as in x-ray images.
IG_IP_contrast_gamma() Adjusts the contrast of the image non-linearly, using an algorithm that tends to correct for the non-linear response of display monitor phosphors, video camera photoreceptors, and photographic emulsions.
IG_IP_contrast_invert() Inverts each pixel intensity or color, resulting in an image that is a "negative" of the original.

Each of the above functions can operate on any specified rectangular portion of your image. However, when operating on an entire image, each function above can achieve its effect by altering the image's palette instead of by altering its pixel values. An example of a call to an IG_IP_contrast_ ...() function is:

 
Copy Code
HIGEAR hIGear; /* HIGEAR handle of image */
AT_RECT rcRect; /* rectangle to operate on */IG_IP_contrast_equalize ( hIGear, &rcRect, IG_CONTRAST_PIXEL);

If you specify IG_CONTRAST_PALETTE instead of IG_CONTRAST_PIXEL, note that your rectangle argument will be ignored, and the operation will be performed on the entire image.

Several additional functions help you to highlight contrast boundaries:

IG_IP_edge_map() Produces an image that shows where there are contrast changes in the original image. An area in which there are no contrast changes is black in the resultant image; the stronger the contrast change, the brighter the result. The result tends to have bright lines where there are sharp contrast changes.
IG_IP_pseudocolor_small_grads() Colors an 8-bit gray level image according to the local rate of pixel value change. This can be set to expose even very small gradients in brightness.
IG_IP_pseudocolor_limits() Allows you to block out, to a single color, all pixels below (or above) a given pixel value. This can be used to highlight the portion of an image that is relevant (then IG_IP_contrast_stretch() might be called to enhance its contrast), or may be used to see what portions of the image are saturated or unsaturated.

Refer to the descriptions of all of the above in Core Component API Function Reference.