欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C#圖像處理之頭發(fā)檢測(cè)的方法

 更新時(shí)間:2015年04月24日 10:09:56   作者:滄海一粟……  
這篇文章主要介紹了C#圖像處理之頭發(fā)檢測(cè)的方法,可實(shí)現(xiàn)針對(duì)圖像中頭發(fā)的檢測(cè)功能,非常具有實(shí)用價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了C#圖像處理之頭發(fā)檢測(cè)的方法。分享給大家供大家參考。具體如下:

//發(fā)色檢測(cè)(YCbCr顏色空間)
public Bitmap HairD(Bitmap a)
{
  Rectangle rect = new Rectangle(0, 0, a.Width, a.Height);
  System.Drawing.Imaging.BitmapData bmpData = a.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
  int stride = bmpData.Stride;
  unsafe
  {
   byte* pIn = (byte*)bmpData.Scan0.ToPointer();
   byte* p;
   int R, G, B;
   double Cr, Cb,BrightV;
   for (int y = 0; y < a.Height; y++)
   {
     for (int x = 0; x < a.Width; x++)
     {
     p = pIn;
     R = p[2];
     G = p[1];
     B = p[0];
     Cb = 128 - 37.797 * R / 255 - 74.203 * G / 255 + 112 * B / 255;
     Cr = 128 + 112 * R / 255 - 93.768 * G / 255 - 18.214 * B / 255;
     BrightV = (R + G + B) / 3;
     if (!(Cb >= 115 && Cb <= 141 && Cr >= 115 && Cr <= 143 && (R < 35)))
     {
       pIn[0] = (byte)255;
       pIn[1] = (byte)255;
       pIn[2] = (byte)255;
     }
     pIn += 3;
     }
     pIn += stride - a.Width * 3;
   }
  }
  a.UnlockBits(bmpData);
  return a;
}
//定義最小值函數(shù)
public double Min(double a, double b, double c)
{
  double e = (a <= b ? a : b) <= c ? (a <= b ? a : b) : c;
  return e;
}
//定義最大值函數(shù)
public int Max(int a, int b, int c)
{
  int e = (a >= b ? a : b) <= c ? c : (a >= b ? a : b);
  return e;
}

結(jié)果圖像效果:

希望本文所述對(duì)大家的C#程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論