SetLevels
Top  Previous  Next

Description

Sets the levels for the Window/Level operation. If the WindowLevel 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]
objActiveGige.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()
ActiveGige1.Acquire=
True

HScroll1.Min = 0
HScroll1.Max = 100
HScroll2.Min = 0
HScroll2.Max = 100
ActiveGige1.WindowLevel=
True

End Sub


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

Private Sub
 HScroll2_Scroll()
L1 = HScroll1.Value
L2 = HScroll2.Value
ActiveGige1.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 following table shows the maximum pixel value for standard GigE Vision formats

Pixel Format
Maximum pixel value
Mono8
255
Mono10, Mono10Packed
1023
Mono12, Mono12Packed
4095
Mono14
16383
Mono16
65535
Bayer**8, RGB8Packed, BGR8Packed, RGBA8Packed, BGRA8Packed, YUV411PAcked, YUV422Packed, YUV444Packed, RGB8Planar
255
Bayer**10, RGB10Packed, BGR10Packed, BGR10V1Packed, BGR10V2Packed, RGB10Planar
1023
Bayer**12, RGB12Packed, BGR12Packed, RGB12Planar
4095
RGB16Planar
65535


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.