Dim bt As Bitmap = args(0)
Dim vType As Integer = args(1)
Select vType
Case 1 '默认锐化
Dim filter As AForge.Imaging.Filters.Sharpen = New AForge.Imaging.Filters.Sharpen() '默认算子是 {{0, -1, 0}, {-1, 5, -1}, {0, -1, 0}}
filter.ApplyInPlace(bt)
Return bt
Case 2 '高斯锐化,要添加AForge.Math.dll和AForge.Genetic.dll的引用,参数可以为空,参数:创建内核的大小等于11和高斯西格玛值等于4的滤波器
Dim filter As AForge.Imaging.Filters.GaussianSharpen = New AForge.Imaging.Filters.GaussianSharpen() '(4, 11) '使用这个参数耗时明显增加,有待研究
filter.ApplyInPlace(bt)
Return bt
Case 3 '自定义卷积滤镜
Dim kernel(,) As Integer = {{-1, -1, -1}, {-1, 9, -1}, {-1, -1, -1}} '可以换不同的算子测试 {{0, -1, 0}, {-1, 5, -1}, {0, -1, 0}} & 浮雕内核 {{-2,-1,0},{-1,1,1},{0,1,2}} & {{-1, -1, -1}, {-1, 9, -1}, {-1, -1, -1}}
Dim filter As AForge.Imaging.Filters.Convolution = New AForge.Imaging.Filters.Convolution(kernel)
filter.ApplyInPlace(bt)
Return bt
Case 4 '黑白图片
Dim filter As AForge.Imaging.Filters.Grayscale = New AForge.Imaging.Filters.Grayscale( 0.2125, 0.7154, 0.0721 )
Return filter.Apply(bt)
Case 5 '调整亮度
Dim filter As AForge.Imaging.Filters.BrightnessCorrection = New AForge.Imaging.Filters.BrightnessCorrection(30) '调整亮度
filter.ApplyInPlace( bt)
Return bt
Case 6 '调整对比度
Dim filter1 As AForge.Imaging.Filters.ContrastCorrection = New AForge.Imaging.Filters.ContrastCorrection(50) '调整对比度
filter1.ApplyInPlace( bt)
Return bt
Case 7 '调整饱和度
Dim filter1 As AForge.Imaging.Filters.SaturationCorrection = New AForge.Imaging.Filters.SaturationCorrection(-0.5) '调整饱和度
filter1.ApplyInPlace( bt)
Return bt
Case 8
Dim filter As AForge.Imaging.Filters.HistogramEqualization = New AForge.Imaging.Filters.HistogramEqualization()
filter.ApplyInPlace( bt)
Return bt
Case 9
'Dim filter As AForge.Imaging.Filters.HSLLinear= New AForge.Imaging.Filters.HSLLinear() 'HSL 水平线性校正,提供亮度和饱和度线性校正功能
'filter.InLuminance = new AForge.Range( 0, 0.85 ) 'API文档是DoubleRange,FT中不行,要用Range
'filter.OutSaturation = new AForge.Range( 0.25, 1 )
'filter.ApplyInPlace( bt)
'Return bt
End Select