Image Processing: Contrast Enhancement 1

The following programming example shows how you can use IC Imaging Control to enhance the contrast of an image.
Language:Visual Basic 6
Version:3.0.3
Released on:August 20, 2006
Author:IC Imaging Control Support Department
Requirements:IC Imaging Control >2.1
Camera, converter or grabber with WDM Stream Class drivers.

It shows how you can use a ready-to-use filter in IC Imaging Control. For details, please refer to the chapter Frame Filters in the IC Imaging Control documentation.

The sample application's window looks as follows:

The Testdialog of IC Imaging Control,

The property dialog of the filter.

The filter used here performs a contrast enhancement. It maps the pixel values between a min and max value to the entire value range from 0 to 255. The pixel values that are below the min value are set to 0. The pixel values that are above the max value are set to 255. The parameter "Enable" allows the filter to be switched on and off. The min and max values can be altered, using a built-in dialog. Please feel free to download the filter's C++ source code from the top of this page. Please note that it is not required in order to understand the following programming example. It should be considered as background information. At the beginning, the program shows a built-in dialog that allows a device to be selected (.ShowDeviceSettingsDialog). In a second step, the filter "ContrastEnhancement" is loaded and inserted in the device path of IC Imaging Control. In a third step, the filter is enabled and the live stream is started (.LiveStart).

Private Sub Form_Load()
    ICImagingControl1.ShowDeviceSettingsDialog
    If Not ICImagingControl1.DeviceValid Then
        Unload Me
        Exit Sub
    End If
    Set filter = ICImagingControl1.FrameFilterCreateString("ContrastEnhancement", "")
    ' Insert the frame filter in the device path of IC.
    ICImagingControl1.DeviceFrameFilters.Add filter
    ' Enable the filter
    cbEnable.Value = Checked
    ' Initialize the Enable check box.
    filter.Parameter("Enable") = cbEnable.Value
    ICImagingControl1.LiveStart
End Sub

The filter can be switched on and off using the checkbox "Enable".

Private Sub btParameter_Click()
    filter.ShowDialog
    If filter.Parameter("Enable") Then
        cbEnable.Value = Checked
    Else
        cbEnable.Value = Unchecked
    End If
End Sub

The method .ShowDialog displays the built-in dialog for setting up the min an max value. After the dialog has been closed, the checkbox cbEnable has to be synchronized with the filter parameter "Enable" because this parameter might have been altered in the dialog.

Private Sub cbEnable_Click()
    filter.BeginParameterTransfer
    filter.Parameter("Enable") = cbEnable.Value
    filter.EndParameterTransfer
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.