title: I have a function that creates histogram of each Bitmap. How can I create another 3 histograms for R.G.B of each Bitmap?
body: <p>This is the histogram function I'm using today and if I'm not wrong it's creating an histogram by Gray color. </p>
  
  <p>What i want is another function that will return me 3 histograms of each Bitmap:</p>
  
  <p>The first histogram will be of the Red color of the bitmap the second for the Green color and the last one for the Blue color.</p>
  
  <pre><code>public static long[] GetHistogram(Bitmap b)
          {
              long[] myHistogram = new long[256]; 
              BitmapData bmData = null;
  
              try
              {
                  //Lock it fixed with 32bpp
                  bmData = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
                  int scanline = bmData.Stride;
                  System.IntPtr Scan0 = bmData.Scan0;
                  unsafe
                  {
                      byte* p = (byte*)(void*)Scan0;
                      int nWidth = b.Width;
                      int nHeight = b.Height;
                      for (int y = 0; y &lt; nHeight; y++)
                      {
                          for (int x = 0; x &lt; nWidth; x++)
                          {
                              long Temp = 0;
                              Temp += p[0]; //  p[0] - blue, p[1] - green , p[2]-red
                              Temp += p[1];
                              Temp += p[2];
                              Temp = (int)Temp / 3;
                              myHistogram[Temp]++;
                              //we do not need to use any offset, we always can increment by pixelsize when
                              //locking in 32bppArgb - mode
                              p += 4;
                          }
                      }
                  }
                  b.UnlockBits(bmData);
              }
              catch
              {
                  try
                  {
                      b.UnlockBits(bmData);
                  }
                  catch
                  {
                  }
              }
              return myHistogram;
         }
  </code></pre>
  
  <p>How may I do it ?</p>