Emgucv (用c#调用 sharp版 opencv)中的函数,会引起内存泄漏(如下语句),所以改用Aforge实现
Bitmap bmp = new Bitmap("D:\\4.png");
while(true)
{
Image<Gray, Byte> img = new Image<Gray, Byte>(bmp);
}
1.官网下载
http://www.aforgenet.com/framework/downloads.html
下载不下来,可以到此链接下下载
http://download.csdn.net/download/robert_cheng/572660
2.如何配置Aforge
建立一份c# 工程,引用下载的Aforge中的dll(在子文件夹中),项目需要,我只引用了Aforge.dll, Aforge.Imaging.dll和Aforge.Math.dll
如下图所示:
程序开头引用一下:
using AForge;
using AForge.Imaging;
using AForge.Imaging.Filters;
using AForge.Imaging.Textures;
接下来就可以使用了(具体可以参见down下来的sample例子),这边我写个sample,进行简单的二值化
Bitmap image = new Bitmap(@"D:\new.png");
AForge.Imaging.Image.Clone(image, PixelFormat.Format8bppIndexed);
Threshold threshold = new Threshold();
threshold.ThresholdValue = threshold_value;
Bitmap binaryimage = threshold.Apply(image);
binaryimage.Save("D:\\gray.png");