我正在尝试学习 Aforge.net。我编写了代码,它工作正常,但我想检测图像上的紫色,但我不知道它是怎么回事。所以有人可以帮助我吗? 这是我的代码
Bitmap resim = new Bitmap(pictureBox1.Image);
EuclideanColorFiltering filter = new EuclideanColorFiltering();
// set center color and radius
filter.CenterColor = new RGB(80,90,120);
filter.Radius = 40;
// apply the filter
filter.ApplyInPlace(resim);
pictureBox1.Image = resim;
这是我的源图像
经过我的过滤后是这样的
那么我该怎么做才能在这张图片中只选择紫色数字而不选择其他东西或只选择紫色东西呢?
最佳答案
我建议您使用HSLFilter,以获得更好的颜色过滤
HSLFiltering filter = new HSLFiltering();
filter.Saturation = new Range(0.05f, 1f);
filter.Luminance = new Range(0.05f, 0.70f);
filter.Hue = new IntRange(280, 340); //these settings should works, if not
Bitmap red = filter.Apply(image); //search "HSL color picker online" to tune it
在颜色过滤步骤之后,您可以继续进行 Blob 过滤步骤。
过滤每个 Blob :
1. Have a Width more than 20%(example) of the Image.Width (for the height too)
2. Have a too much/too poor fullness (blob.fullness)
3. Have a not good ratio Width/Height
最后你应该只有数字或者至少多 1-2 个 Blob
关于C# aforge 颜色检测,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16502384/