这是我用手检测图像肤色的代码,但检查每张照片大约需要5分钟...有谁知道如何以更快的方式实现它?谢谢!
using (Bitmap SampleImage = (Bitmap)Image.FromFile (path)) {
for (int x = 0; x < SampleImage.Width; x++) {
for (int y = 0; y < SampleImage.Height; y++) {
Color pixelColor = SampleImage.GetPixel (x, y);
int r = pixelColor.R;
int g = pixelColor.G;
int b = pixelColor.B;
int differenceMinMax =
Math.Max (r, Math.Max (g, b)) - Math.Min (r, Math.Min (g, b));
if (r > 95 & g > 40 & b > 20 & differenceMinMax > 15 & r > g & r > b) {
SampleImage.SetPixel (x, y, Color.White);
} else if (r > 220 & g > 210 & b > 170) {
SampleImage.SetPixel (x, y, Color.White);
} else {
SampleImage.SetPixel (x, y, Color.Black);
}
SampleImage.Save (path, System.Drawing.Imaging.ImageFormat.Jpeg);
}
}
}
答案 0 :(得分:0)