
| 語言: | Visual Basic 6 |
| 版本: | 3.0.3 |
| 发布于: | 2006年8月20日 |
| 作者: | IC Imaging Control 技術支持部 |
| 需求: | IC Imaging Control >2.1 由WDM數據流類驅動程序驅動的相機、視頻轉換器或圖像采集卡 |
| |
本節將演示如何直接在你的程序裏調節對比度的參數,而非通過一個內置濾鏡對話框。
示例程序窗口如圖所示:

這個濾鏡將對圖像實施柱狀圖擴展操作,即處於最大和最小值之間的灰度值將被按比例映射為0~255之間的值, 小於最小值的像素灰度值將被設為0,大於最大值的會制度將被設為255。而最大值和最小值可通過兩個 scrollbars (sldLowerBound and sldUpperBound)進行調節。程序開始時首先調用兩個函數進行初始化。
InitControls UpdateControls
函數 InitControls 將初始化scrollbars的最小值與最大值。
Private Sub InitControls() sldLowerBound.Min = 0 sldLowerBound.Max = 255 sldUpperBound.Min = 0 sldUpperBound.Max = 255 End Sub
函數 UpdateControls 將濾鏡參數 "Enable"、"Lower Bound" 及 "Upper Bound" 賦值給復選框 cbEnable 和 scrollbars sldLowerBound 與 sldUpperBound。
Private Sub UpdateControls() If filter.Parameter("Enable") Then cbEnable.Value = Checked Else cbEnable.Value = Unchecked End If sldLowerBound.Value = filter.Parameter("Lower Bound") txLowerBound.Text = sldLowerBound.Value sldUpperBound.Value = filter.Parameter("Upper Bound") txUpperBound.Text = sldUpperBound.Value End Sub
scrollbar sldLowerBound 的事件處理程序將確保它的值小於等於 scrollbar sldUpperBound 的值。之後,scrollbar 的值將被賦予濾鏡參數 "Lower Bound",同時scrollbar 右側的顯示文字將被更新。scrollbar sldUpperBound 的事件處理程序的原理也類似。
Private Sub sldLowerBound_Scroll() If sldLowerBound.Value >= sldUpperBound.Value Then sldLowerBound.Value = sldUpperBound.Value - 1 End If filter.Parameter("Lower Bound") = sldLowerBound.Value txLowerBound.Text = sldLowerBound.Value End Sub
責任聲明
IC Imaging Control源代碼庫中的所有代碼均只用於教學目的,The Imaging Source Europe GmbH作為IC Imaging Control的開發製造商,不對任何由於使用本文或其中源代碼所產生的後果承擔責任。