顯示現場視頻: 標記過度曝光和曝光不足的像素-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.