显示现场视频: 标记过度曝光和曝光不足的像素-2

这个示例程序演示的是如何通过编程,控制标记像素时所需的各个参数。
语言:.NET C#/Visual Basic
版本:3.0.3
发布于:2006年8月20日
作者:IC Imaging Control 技术支持部
系统要求:IC Imaging Control >2.1
由WDM数据流类驱动程序驱动的相机、视频转换器或图像采集卡

程序窗口如图所示:

The Testdialog of IC Imaging Control,

这个程序将演示如何直接在程序中,而不是通过滤镜的内置对话框,调节标记过度曝光或曝光不足的像素时的各个参数。

滤镜的 VC++ .NET 项目可从页面上方的链接处下载,但对于运行和掌握这个示例程序,读者不必理解滤镜的源代码。

首先在类Form1中声明一个TIS.Imaging.FrameFilter类型的变量filter,用于保存帧滤镜和与之交换数据。

[C#]
private TIS.Imaging.FrameFilter filter;
[VB.NET]
Private filter As TIS.Imaging.FrameFilter

滤镜提供了下列参数:阈值("Threshold"),参数"ClipAboveThreshold",以及标记像素时的色彩和模式("FillMode" and "FillColor")。

用户可通过 scrollbar sldThreshold 调节阈值大小。 是否标记高于或低于阈值的像素通过两个 radio buttons rbClipAboverbClipBelow 控制。 程序开始时调用两个函数,用于初始化主窗体中的控件。

[C#]
InitControls();
UpdateControls();
[VB.NET]
InitControls()
UpdateControls()

函数 InitControls 初始化scrollbar sldThreshold的最大值和最小值。

[C#]
private void InitControls()
{
    sldThreshold.Minimum = 0;
    sldThreshold.Maximum = 255;
}
[VB.NET]
Private Sub InitControls()
    sldThreshold.Minimum = 0
    sldThreshold.Maximum = 255
End Sub

函数 UpdateControls 将滤镜的参数 "Enable"、"Threshold" 和 "ClipAboveThreshold" 赋值给复选框 cbEnable、scrollbar sldThreshold 和 radio buttons rbClipAbove and rbClipBelow

[C#]
private void UpdateControls()
{

    filter.BeginParameterTransfer();

    // Update the "Enable" checkbox.
    cbEnable.Checked = filter.GetBoolParameter("Enable");

    // Update the radio buttons.
    bool state = filter.GetBoolParameter("ClipAboveThreshold");
    rbClipAbove.Checked = state;
    rbClipBelow.Checked = !state;

    // Update the slider.
    sldThreshold.Value = filter.GetIntParameter("Threshold");
    txThreshold.Text = sldThreshold.Value.ToString();

    filter.EndParameterTransfer();

}
[VB.NET]
Private Sub UpdateControls()

    filter.BeginParameterTransfer()

    ' Update the "Enable" checkbox.
    cbEnable.Checked = filter.GetBoolParameter("Enable")

    ' Update the radio buttons.
    Dim state As Boolean = filter.GetBoolParameter("ClipAboveThreshold")
    rbClipAbove.Checked = state
    rbClipBelow.Checked = Not state

    ' Update the slider.
    sldThreshold.Value = filter.GetIntParameter("Threshold")
    txThreshold.Text = sldThreshold.Value

    filter.EndParameterTransfer()
End Sub

sldThreshold 的事件处理程序将其当前值赋予滤镜参数"Threshold",并将其显示文字txThreshol更新为这个值。

[C#]
private void sldThreshold_Scroll(object sender, System.EventArgs e)
{
    filter.BeginParameterTransfer();
    filter.SetIntParameter("Threshold", sldThreshold.Value);
    filter.EndParameterTransfer();
    txThreshold.Text = sldThreshold.Value.ToString();
}
[VB.NET]
Private Sub sldThreshold_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles sldThreshold.Scroll
    filter.BeginParameterTransfer()
    filter.SetIntParameter("Threshold", sldThreshold.Value)
    filter.EndParameterTransfer()
    txThreshold.Text = sldThreshold.Value
End Sub

rbClipAbove 的事件处理程序把True值赋予滤镜参数"ClipAboveThreshold",反选radio button rbClipBelowrbClipBelow 的事件处理程序同理。

[C#]
private void rbClipAbove_CheckedChanged(object sender, System.EventArgs e)
{
    filter.BeginParameterTransfer();
    filter.SetBoolParameter("ClipAboveThreshold", true);
    filter.EndParameterTransfer();
    rbClipBelow.Checked = false;
}

private void rbClipBelow_CheckedChanged(object sender, System.EventArgs e)
{
    filter.BeginParameterTransfer();
    filter.SetBoolParameter("ClipAboveThreshold", false);
    filter.EndParameterTransfer();
    rbClipAbove.Checked = false;
}
[VB.NET]
Private Sub rbClipBelow_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbClipBelow.CheckedChanged
    filter.BeginParameterTransfer()
    filter.SetBoolParameter("ClipAboveThreshold", False)
    filter.EndParameterTransfer()
    rbClipAbove.Checked = False
End Sub

Private Sub rbClipAbove_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbClipAbove.CheckedChanged
    filter.BeginParameterTransfer()
    filter.SetBoolParameter("ClipAboveThreshold", True)
    filter.EndParameterTransfer()
    rbClipBelow.Checked = False
End Sub

相关源代码示例

责任声明
IC Imaging Control 源代码库中的所有代码均只用于教学目的,The Imaging Source Europe GmbH 作为IC Imaging Control的开发制造商,不对任何由于使用本文或其中源代码所产生的后果承担责任。

该网站为The Imaging Source网络的一部分。其它的站点包括 公司, Imaging, 天文相机, Astronomy Cameras Blog, Blog caméras d'astronomie, 天文相机有奖竞答, TX Text Control, LiveDocx, phpLiveDocxForum.