IC Imaging Control .NET

Adjust Image Settings

Adjust Image Settings

This chapter shows you how to adjust image settings such as brightness, contrast, saturation, etc.

The source code for the VB.NET and C# versions of this sample program can be found in the directories samples\VB *\Adjusting Image Settings and samples\C# *\Adjusting Image Settings in your My Documents/IC Imaging Control 3.4 directory.

Setting up the Project

Create a new project and add IC Imaging Control to the form as shown in the FirstSteps chapter.

Add a Label control and a Slider to the form. Set the Label control's Text property to "Brightness".

image

Image Settings such as brightness are provided through the VCDRangeProperty. To enable easy access to the range properties, this sample uses the VCDSimpleProperty class. This class is declared in the TIS.Imaging.VCDHelpers namespace. Please add the namespaces to the form:

[VB.NET]
Imports TIS.Imaging Imports TIS.Imaging.VCDHelpers
[C#]
using TIS.Imaging; using TIS.Imaging.VCDHelpers;

Writing the source code

First of all add a new variable to your form:

[VB.NET]
private VCDProp as VCDSimpleProperty
[C#]
private VCDSimpleProperty VCDProp;

You then need to initialize the VCDProp variable to get access to the properties of the video capture device.

[VB.NET]
VCDProp = VCDHelpers.VCDSimpleModule.GetSimplePropertyContainer(IcImagingControl1.VCDPropertyItems)
[C#]
VCDProp = VCDHelpers.VCDSimpleModule.GetSimplePropertyContainer(icImagingControl1.VCDPropertyItems);

Then the slider is initialized, thus it has the correct value for minimum and maximum.

After initializing the range, the VCDProp.RangeValue(VCDID_Brightness) return value is used to initialize the thumb position of the slider. A call to the LiveStart method starts the live image display.

[VB.NET]
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If IcImagingControl1.ShowDeviceSettingsDialog = DialogResult.OK Then IcImagingControl1.LiveStart() VCDProp = VCDSimpleModule.GetSimplePropertyContainer(IcImagingControl1.VCDPropertyItems) ' Setup the range of the brightness slider. trackBar1.Minimum = VCDProp.RangeMin(VCDIDs.VCDID_Brightness) trackBar1.Maximum = VCDProp.RangeMax(VCDIDs.VCDID_Brightness) ' Set the slider to the current brightness value. trackBar1.Value = VCDProp.RangeValue(VCDIDs.VCDID_Brightness) Else System.Windows.Forms.MessageBox.Show("No device was selected.", Me.Text, System.Windows.Forms.MessageBoxButtons.OK, MessageBoxIcon.Information) Me.Close() End If End Sub
[C#]
private void Form1_Load(object sender, EventArgs e) { if (icImagingControl1.ShowDeviceSettingsDialog() == DialogResult.OK) { icImagingControl1.LiveStart(); VCDProp = VCDSimpleModule.GetSimplePropertyContainer(icImagingControl1.VCDPropertyItems); // Setup the range of the brightness slider. trackBar1.Minimum = VCDProp.RangeMin(VCDIDs.VCDID_Brightness); trackBar1.Maximum = VCDProp.RangeMax(VCDIDs.VCDID_Brightness); // Set the slider to the current brightness value. trackBar1.Value = VCDProp.RangeValue[VCDIDs.VCDID_Brightness]; } else { MessageBox.Show("No device was selected.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } }

Finally, only a single line of code is required to adjust the brightness setting when the slider is moved:

[VB.NET]
Private Sub trackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles trackBar1.Scroll VCDProp.RangeValue(VCDIDs.VCDID_Brightness) = trackBar1.Value End Sub
[C#]
private void trackBar1_Scroll(object sender, EventArgs e) { VCDProp.RangeValue[VCDIDs.VCDID_Brightness] = trackBar1.Value; }

You are now ready to run the program, and move the slider's thumb with the mouse to adjust brightness. All image settings are handled in the same way, so once you know how to adjust brightness, you also know how to handle contrast, hue, zoom, and all the other settings.

<< Programmer's Guide

Get in touch with us


About The Imaging Source

Established in 1990, The Imaging Source is one of the leading manufacturers of industrial cameras, frame grabbers and video converters for production automation, quality assurance, logistics, medicine, science and security.

Our comprehensive range of cameras with USB 3.1, USB 3.0, USB 2.0, GigE interfaces and other innovative machine vision products are renowned for their high quality and ability to meet the performance requirements of demanding applications.

Automated Imaging Association ISO 9001:2015 certified

Contact us