Mark Underexposed and Overexposed Pixels - Part 1 This source code snippet illustrates how to mark underexposed and overexposes pixels, using a ready-to-use filter in IC Imaging Control.
Language: | .NET C#/Visual Basic
Version: | 3.3
Author: | IC Imaging Control Support Department
Requirements: |
Software: | IC Imaging Control 3.3, Visual Studio™ 2010
Hardware: | Camera, converter or grabber with WDM Stream Class drivers.
Download C# sample | Mark Pixels1 - C#
Download VB7 sample | Mark Pixels1 - VB7
Download Clipping Frame Filter C++ project | Clipping Frame Filter - C++

There is an entire chapter dedicated to Frame Filters in the IC Imaging Control documentation. Interested readers are encouraged to take a look at this chapter.

The filter used here marks pixels, which are below or above a pre-determined brightness threshold.

The frame filter's VC++ .NET project can also be downloaded from the top of this page. Please note that the frame filter's source code is not required in order to run and understand the following programming example.

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

    C#

    public TIS.Imaging.FrameFilter filter;

    VB.NET

    Private filter As TIS.Imaging.FrameFilter

The program starts off by showing a built-in dialog that allows a video capture device to be selected (.ShowDeviceSettingsDialog).

In a second step, the filter "Clipping" is loaded and inserted in the display path of IC Imaging Control.

In a third step, the filter is enabled and the live stream is started (.LiveStart).

    C#

    private void Form1_Load(object sender, System.EventArgs e)
    {
        icImagingControl1.ShowDeviceSettingsDialog();
        if (!icImagingControl1.DeviceValid )
            return ;

        filter = icImagingControl1.FrameFilterCreate("Clipping", "");
        // Check for successful load of filter.
        if (filter == null)
        {
            MessageBox.Show("Failed to load the Clipping filter", "Mark Pixels 1", MessageBoxButtons.OK, MessageBoxIcon.Error);
            cbEnable.Checked = false;
            cbEnable.Enabled = false;
        }
        else
        {
            // Insert the frame filter in the display path of IC.
            icImagingControl1.DisplayFrameFilters.Add(filter);
            // Enable the filter
            filter.SetBoolParameter("Enable", cbEnable.Checked);
            // Initialize the Enable check box.
            cbEnable.Checked = true;
        }
        icImagingControl1.LiveStart();
    }

    VB.NET

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        IcImagingControl1.ShowDeviceSettingsDialog()
        If Not IcImagingControl1.DeviceValid Then
            'Unload(Me)
            Exit Sub
        End If

        filter = IcImagingControl1.FrameFilterCreate("Clipping", "")

        ' Insert the frame filter in the display path of IC.
        IcImagingControl1.DisplayFrameFilters.Add(filter)
        ' Enable the filter
        filter.SetBoolParameter("Enable", cbEnable.Checked)
        ' Initialize the Enable check box.
        cbEnable.Checked = True

        IcImagingControl1.LiveStart()
    End Sub

The image processing in the frame filter can be toggled by clicking on the checkbox cbEnable. The parameter "Enable" of the frame filter is set in the change event handler of the checkbox, This toggles the image processing.

    C#

    private void cbEnable_CheckedChanged(object sender, System.EventArgs e)
    {
        filter.BeginParameterTransfer();
        filter.SetBoolParameter("Enable", cbEnable.Checked);
        filter.EndParameterTransfer();
    }

    VB.NET

    Private Sub cbEnable_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbEnable.CheckedChanged
        filter.BeginParameterTransfer()
        filter.SetBoolParameter("Enable", cbEnable.Checked)
        filter.EndParameterTransfer()
    End Sub

The method .ShowDialog displays the built-in dialog allows the following parameters to be set: the brightness threshold; whether pixels are marked that are underexposed or overexposed; the brightness threshold; the color or pattern that is used to mark the pixels. After the dialog has been closed, the checkbox bEnable has to be synchronized with the filter parameter "Enable", as this parameter may have been altered in the dialog.

    C#

    private void btParameter_Click(object sender, System.EventArgs e)
    {
        filter.ShowDialog();
        cbEnable.Checked = filter.GetBoolParameter("Enable");
    }

    VB.NET

    Private Sub btParameter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btParameter.Click
        filter.ShowDialog()
        cbEnable.Checked = filter.GetBoolParameter("Enable")
    End Sub