以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]怎样运行这段图片锐化代码 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=109346) |
-- 作者:天一生水 -- 发布时间:2017/11/9 22:22:00 -- [求助]怎样运行这段图片锐化代码 原贴地址:http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=101287&replyID=696000&skin=1 按照原贴要求引用各DLL文件后,“去灰底”代码运行无误。下列“锐化”代码运行提示:“未声明名称args” 请老师帮助看看,怎样声明“args”。
原代码: ‘引用AForge.dll,AForge.Imaging.dll,AForge.Math.dll和AForge.Genetic.dll (AForge基础库,图像处理类库,数学算法库,遗传算法库)
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 |
-- 作者:有点甜 -- 发布时间:2017/11/9 22:35:00 -- 1、代码放到内部函数里,加入命名为abc
http://www.foxtable.com/webhelp/scr/1486.htm
2、调用的时候,传入图片和用途,如
dim img = Functions.Execute("abc", getimage("d:\\test.jpg"), 3) |
-- 作者:天一生水 -- 发布时间:2017/11/10 11:46:00 -- 按照老师的指点,但运行代码没有效果。更换用途序号后也不报错但也没效果。 代码如下: Dim img = Functions.Execute("abc", getimage(e.Form.Controls("TextBox1").value), 4) ----- e.Form.Controls("TextBox1").value 显示的是图片路径
[此贴子已经被作者于2017/11/10 11:49:46编辑过]
|
-- 作者:有点甜 -- 发布时间:2017/11/10 12:04:00 -- 得到的图片,再显示给picturebox不就好了?
Dim img = Functions.Execute("abc", getimage(e.Form.Controls("TextBox1").text), 4) e.Form.Controls("pictureBox1").Image = img |
-- 作者:天一生水 -- 发布时间:2017/11/10 12:20:00 -- 谢谢! |