SetLevels
Top  Previous  Next

Description

Sets the levels for the Window/Level operation. If the LUTMode property is enabled, the operation performs a linear scaling of the histogram of each video frame thus optimizing the contrast, brightness and color of the video.

The lower limit indicates the darkest pixel value that will be mapped to the black (zero) level of the image or its color component. The upper limit indicates the brightest pixel value that will be mapped to the maximum pixel value of the image or its color component. Increasing the lower limit will make the shadows of the image darker. Decreasing the upper limit will make the highlights of the image brighter.

This method also allows you to assign the limits automatically by selecting the Auto Fit or/and Auto White Balance options. The Auto Fit optimizes the values of the lower and upper limits by providing the maximum contrast between the brightest and darkest pixel in the image. The Auto White Balance optimizes the values of the limits of each color component so that the average color of the image (or selected ROI) becomes gray.


Syntax


[VB]
objActiveDcam.SetLevels minR, maxR [, minB, maxG, minB , maxB]


[C/C++]
HRESULT SetLevels(long minR, long maxR, long minG, long maxG, long minB, long maxB);


Data Types
[VB]

minR, maxR: Long
minG, maxG, minB, maxB: Long (optional)


Parameters
[C/C++]

minR [in], maxR [in]  
Lower and upper limits for a monochrome image or for the red channel of a color image. The values are given in percents of the maximum pixel value for the currently selected image format.  
 
If minR is set to -1, all the limits will be set automatically based on the Auto Fit algorithm.  
 
If minR is set to -2, all the limits will be adjusted automatically based on the Auto White Balance algorithm.  
 
minB [in], maxB [in], minG [in], maxG [in]  
Lower and upper limits for the green and blue channels. If these parameters are omitted or set to zero, the green and blue channels are scaled proportionally with the red channel thus preserving the colors on the image. These parameters are ignored for a monochrome video.  


Return Values


S_OK  
Success  
E_FAIL  
Failure.  

Example

The following VB example uses a slider to adjust the brightness and contrast of the video without changing its color:

Private Sub
 Form_Load()
ActiveDcam1.Acquire=
True

HScroll1.Min = 0
HScroll1.Max = 100
HScroll2.Min = 0
HScroll2.Max = 100
ActiveDcam1.LUTMode=
True

End Sub


Private Sub HScroll1_Scroll()
L1 = HScroll1.Value
L2 = HScroll2.Value
ActiveDcam1.SetLevels L1, L2
End Sub

Private Sub
 HScroll2_Scroll()
L1 = HScroll1.Value
L2 = HScroll2.Value
ActiveDcam1.SetLevels L1, L2
End Sub



Remarks


The limits for the Window/Level operation are given in percents of the maximum pixel value for the currently selected image format.

The Auto Fit and Auto White Balance algorithms work on the currently selected SetROI. When applying the Auto White Balance, make sure to select the ROI corresponding to the gray area in the image.

To retrieve the values of the limits assigned by SetLevels, use the GetLevels method.