/// <summary> /// Returns a gray scale image that contains intensity of the specified image. /// </summary> /// <param name="source">A <see cref="BitmapSource"/> to compute luminance.</param> /// <returns>The new <see cref="ByteImage"/>.</returns> /// <remarks>The coefficient is (1/3. 1/3. 1/3).</remarks> public static ByteImage ToIntensityImage(this BitmapSource source) { var bmp = source.AsGray8(); var data = new byte[bmp.PixelWidth * bmp.PixelHeight]; bmp.CopyPixels(data, bmp.PixelWidth, 0); return(new ByteImage(bmp.PixelWidth, bmp.PixelHeight, data)); }