static public YCbCr[,] ToYcbcr(Bitmap bmp) { var ycbcrBitmap = new YCbCr[512, 512]; using (var fastBitmap = bmp.FastLock()) { for (var y = 0; y < 512; y++) { for (var x = 0; x < 512; x++) { ycbcrBitmap[x, y] = ToYcbcr(fastBitmap.GetPixel(x, y)); } } } return(ycbcrBitmap); }
static public Color ToRgb(YCbCr ycbcr) { return(Color.FromArgb(ToR(ycbcr), ToG(ycbcr), ToB(ycbcr))); }
static public byte ToG(YCbCr ycbcr) { return(NormalizeByte((int)Math.Round(ycbcr.Y - (5329.0 / 15481) * (ycbcr.Cb - 128) - (11103.0 / 15481) * (ycbcr.Cr - 128)))); }
static public byte ToB(YCbCr ycbcr) { return(NormalizeByte((int)Math.Round(ycbcr.Y + (256.0 / 144) * (ycbcr.Cb - 128)))); }
private void ToY() { RightPictureWrapper.Image = YCbCr.ToRgb(YCbCr.ToYcbcr(new Bitmap(LeftPictureWrapper.Image))); }