Live Display: Mark over/underexposed pixels 2

This programming example extents the previous by showing how to control the parameters for the visualization of over and underexposed pixels programmatically.
Language:Visual Basic 6
Version:3.0.3
Released on:August 20, 2006
Author:IC Imaging Control Support Department
Requirements:IC Imaging Control 3.0 or higher
Camera, converter or grabber with WDM Stream Class drivers.

The following example (Visual Basic™6) extents the preceding example Mark over/underexposed pixels 1. It shows how to manipulate the parameters for the visualization of over/underexposed pixels directly in your program instead of using the built-in dialog of the filter that provides the visualization functionality.

The sample application's window looks as follows:

The Testdialog of IC Imaging Control,

First of all a variable filter of type FrameFilter must be declared in Form1. This variable will contain the frame filter and is used to communicate with it.

Dim filter As FrameFilter 'This variable will hold the Clipping filter

The filter provides the following parameters: the treshold ("Threshold"), a parameter indicating whether pixels are marked that are brighter or darker than the threshold ("ClipAboveThreshold") and the color resp. pattern which is used to mark the pixels ("FillMode" und "FillColor"). The threshold can be manipulated with the scrollbar sldThreshold. Whether pixels are marked that are brighter or darker than the threshold is controlled by the 2 radio buttons rbClipAbove und rbClipBelow. The beginning of the program is extended by 2 function calls that initialize the controls on the main form.

InitControls
UpdateControls

The function InitControls initializes the min and max value of the scrollbar sldThreshold.

Private Sub InitControls()
    sldThreshold.Min = 0
    sldThreshold.Max = 255
End Sub

The function UpdateControls assigns the filter parameters "Enable", "Threshold" and "ClipAboveThreshold" to the checkbox cbEnable, the scrollbar sldThreshold and the radio buttons rbClipAbove und rbClipBelow.

Private Sub UpdateControls()
    ' Update the "Enable" checkbox.
    If filter.Parameter("Enable") Then
        cbEnable.Value = Checked
    Else
        cbEnable.Value = Unchecked
    End If

    ' Update the radio buttons.
    If filter.Parameter("ClipAboveThreshold") Then
        rbClipAbove.Value = True
        rbClipBelow.Value = False
    Else
        rbClipAbove.Value = False
        rbClipBelow.Value = True
    End If

    ' Update the slider.
    sldThreshold.Value = filter.Parameter("Threshold")
    txThreshold.Text = sldThreshold.Value
End Sub

The event handler for the scrollbar sldThreshold assigns its current value to the filter parameter "Threshold" and updates the text field txThreshol with this value.

Private Sub sldThreshold_Scroll()
    filter.Parameter("Threshold") = sldThreshold.Value
    txThreshold.Text = sldThreshold.Value
End Sub

The event handler for the radio button rbClipAbove assigns True to the filter parameter "ClipAboveThreshold" and unchecks the radio button rbClipBelow. The event handler for the radio button rbClipBelow works accordingly.

Private Sub rbClipAbove_Click()
    filter.BeginParameterTransfer
    filter.Parameter("ClipAboveThreshold") = True
    filter.EndParameterTransfer
    rbClipBelow.Value = False
End Sub

Related Source Code Samples

Disclaimer
The source code that appears in the IC Imaging Control Source Code Library is indented for educational purposes only. The Imaging Source Europe GmbH, the manufacturer of IC Imaging Control, does not assume any kind of warranty expressed or implied, resulting from the use of the content of this page.

This site is part of The Imaging Source Network. Other sites include Company Portal, Image Processing, Astronomy Cameras, Astronomy Cameras Blog, Blog caméras d'astronomie, Astronomy Cameras Competition, TX Text Control, LiveDocx, phpLiveDocx and Forums.