adjLevels
Top  Previous  Next

adjLevels ( integer Input, integer Output, floating& InpMin, floating& InpMax
   
[, floating& OutMin =0, floating& OutMax =0] )

Use this function to perform the linear scaling of an image or selection according to the selected thresholds.

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 inpMin, InpMax, OutMin, OutMax parameters.  
M_DIALOG=1 – opens the Levels dialog that lets the user adjust the input levels 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 upward makes the minimum input level lower and the maximum input level higher, and vice versa. Moving the mouse leftward or rightward makes both of the input levels lower or higher respectively. As a result, the vertical mouse movement affects the contrast of the image, while the horizontal movement affects the brightness. 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.  
 
InpMin, InpMax  
 
Floating variables or constants, specifying the darkest and lightest level in the input image to be mapped to the output levels. Increasing the minimum input level will make the shadows on the image darker. Decreasing the maximum input level will make the highlights on the image brighter. ). If the function is called in the interactive mode (M_DIALOG or M_MOUSE), these variables will return the selected values of the input levels.  
 
OutMin, OutMax  
 
Optional floating arguments, specifying the levels of black and white in the output image. Increasing the minimum output level will raise the level of black in the output image. Decreasing the maximum output level will lower the level of white in the output image. If the function is called in the interactive mode (M_DIALOG or M_MOUSE), these variables will return the selected values of the output levels. If these arguments are zero or omitted, the output levels will be set according to the pixel value range of the input image type.  
Default values: 0  
 
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 perform the linear scaling of a captured image using the mouse mode and outputs interactively selected parameters to the terminal window. Both output levels are omitted in the function call and therefore set to default values for a given image type.  
 
grabIm (1)  
adjLevels (1, 2, M_MOUSE, imin, imax)  
print "Shadows=", imin  
print "Highlights=", imax  
 
Remarks

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