2013-05-11 129 views
1

我想学习Aforge.net。我写o代码,它工作正常,但我想检测我的形象只是紫色,但我无法找到它是如何。所以任何人都可以帮助我呢? 这里是我的代码C#aforge颜色检测

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; 

,并有我的源图像

我的过滤器后,它是这个

所以我能做些什么来随便挑紫色的数字没有其他的东西或只是紫色的东西在这张照片?

回答

1

我建议你使用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 

颜色过滤步骤中,您可以在斑点过滤步骤进行之后。

过滤器,每个斑点:

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只斑点更