// apply saturation filter to increase green intensity
var f1 = new SaturationCorrection(0.5f);
f1.ApplyInPlace(image);
var filter = new HSLFiltering();
filter.Hue = new IntRange(83, 189); // all green (large range)
//filter.Hue = new IntRange(100, 120); // light green (small range)
// this will convert all pixels outside the range into gray-scale
//filter.UpdateHue = false;
//filter.UpdateLuminance = false;
// this will convert all pixels outside that range blank (filter.FillColor)
filter.Saturation = new Range(0.4f, 1);
filter.Luminance = new Range(0.4f, 1);
// apply the HSV filter to get only green pixels
filter.ApplyInPlace(image);
3 回答
通常,像素值的乘法虽然是对比度的增加,但是增加虽然是亮度的增加 .
在c#中
你有一个数组到图像中的第一个像素,如下所示:
和对比度和亮度值如下:
您可以乘以和/或添加到绿色通道以达到您想要的效果:(r - row,c - column,ch - nr of channels)
显然你会想在这里使用指针加快速度 .
(请注意:此代码尚未经过测试)
对于AFORGE.NET,我建议使用
ColorRemapping
class将绿色通道中的值映射到其他值 . 如果你想增加亮度而不丢失细节,映射函数应该是从[0,255]到[0,255]的凹函数 .这是我在阅读AForge.NET和OpenCV文档的许多页面后想出的 . 如果先应用饱和度过滤器,可能会出现晕眩图像 . 如果您稍后应用它,您将获得更清晰的图像,但在应用HSV滤波器之前可能会丢失一些“浅绿色”像素 .