adjContrast
Top  Previous  Next

adjContrast ( integer Input, integer Output, integer Mode, integer& Brightness,
integer& Contrast, floating& Gamma [, integer Colspace =0] )  

Use this function to adjust the contrast, brightness and gamma of an image or selection in the interactive or automatic mode. Changing contrast and/or brightness means shifting pixel values up or down the tonal range. Adjusting the brightness lightens or darkens all pixels equally, while increasing the contrast can wash out details in shadows and highlights. Gamma correction increases the level of details in an image by enhancing the contrast in very dark or very light areas of the image.

Parameters
 
Input  
 
An integer between 0 and 116 specifying the input image frame number. A value of 0 represents the DMA memory buffer of the video device. Values in the range of 100-116 correspond to hidden frames. If the function is called in the interactive mode (M_DIALOG or M_MOUSE), only visible frames (1-99) can be used.  
 
Output  
 
An integer between 1 and 116 specifying the output image frame number. Values in the range of 100-116 correspond to hidden frames.  
 
Mode  
 
An enumerated integer that describes the mode to use. Must be one of the following values:  
 
M_PRESET=0 – immediately applies the function to the input image using the values specified by the Brightness, Contrast, and Gamma parameters.  
M_DIALOG=1 – opens the Brightness/Contrast dialog that lets the user adjust the brightness, contrast and gamma manually by moving the sliders on the dialog and watching the changes in real time.  
M_MOUSE=2 – activates the mouse mode that lets the user interactively change the settings with a mouse. Moving the mouse downward or upward makes the contrast lower or higher respectively. Moving the mouse leftward or rightward makes the brightness lower or higher respectively. If the mouse has a wheel control, rotating the wheel upward or downward makes the gamma lower or higher respectively. To apply the changes and exit the function, press the left mouse button. To exit the function without applying the changes to the image, press the right mouse button.  
 
Brightness  
 
An integer between –100 and 100 specifying value in per cent to adjust the brightness of the image (the amount of light that is transmitted or reflected from a given pixel). If the function is called in the interactive mode (M_DIALOG or M_MOUSE), the variable will return the selected value of brightness.  
 
Contrast  
 
An integer between –100 and 100 specifying value in per cent to adjust the contrast (the difference in tone between the dark and light areas of an image). If the function is called in the interactive mode (M_DIALOG or M_MOUSE), the variable will return the selected value of contrast.  
 
Gamma  
 
A positive floating variable specifying value in per cent to adjust the gamma of the image. The gamma correction modifies an image by applying standard, nonlinear gamma curves to the intensity scale. A gamma value of 1 is equivalent to the identity curve that does not affect the image. To lighten an image and increase the contrast in its darker areas, specify a gamma value greater than 1. To darken the image and emphasize contrast in the lighter areas, specify a value less than 1. If the function is called in the interactive mode (M_DIALOG or M_MOUSE), the variable will return the selected value of gamma.  
 
Colspace  
 
An optional enumerated integer that describes the mode to use. Must be one of the following values:  
 
M_RGB=0 – process the input image in the RGB color space. Increasing the contrast of the image will result in the increased color saturation.  
M_HLS=1 – process the input image in the HLS color space. Changes in the contrast will not affect the original saturation of the input image.  
Default value: CS_RGB  
 
Error flags

ERR_OK  
 
The flag set if successful.  
 
ERR_FAILED  
 
The flag set if failed.  
 
ERR_CANCEL=-2  
 
The flag set if the function cancelled in the interactive mode.  

Example

This set of statements lets the user adjust the contrast, brightness and gamma of a captured image using the dialog mode and outputs interactively selected parameters to the terminal window.  
 
grabIm (1)  
adjContrast (1, 2, M_DIALOG, b, c, g, CS_HLS)  
print "Brightness=", b  
print "Contrast=", c  
print "Gamma=", g  
 
Remarks

For more information on the Brightness/Contrast dialog box, refer to ImageWarp User's Guide.