/// <summary> /// Get the array of histrgram. /// </summary> /// <param name="src">The source image.</param> /// <returns></returns> public static int[] GetHistogramArray(WriteableBitmap src) ////34 圖像直方圖計算 { if (src != null) { int[] histogram = new int[256]; int gray = 0; byte[] temp = src.PixelBuffer.ToArray(); for (int i = 0; i < temp.Length; i += 4) { gray = (int)(temp[i] * 0.114 + temp[i + 1] * 0.587 + temp[i + 2] * 0.299); histogram[gray]++; } return histogram; } else { return null; } } } }