예제 #1
0
        /// <summary>
        ///     The Working version of YCBCR to RGB conversion.
        ///     Transforms one value of YCBCR to RGB
        /// </summary>
        /// <param name="ycbcr">FROM</param>
        /// <param name="choice">TO</param>
        /// <returns></returns>
        private static Rgb YcbcrToRgbWorking(Ycbcr ycbcr, int choice)
        {
            int r = (int)(1.164 * (ycbcr.Y - 16) + 1.596 * (ycbcr.Cr - 128));
            int g = (int)(1.164 * (ycbcr.Y - 16) - 0.813 * (ycbcr.Cr - 128) - 0.392 * (ycbcr.Cb - 128));
            int b = (int)(1.164 * (ycbcr.Y - 16) + 2.017 * (ycbcr.Cb - 128));

            r = Math.Max(0, Math.Min(255, r));
            g = Math.Max(0, Math.Min(255, g));
            b = Math.Max(0, Math.Min(255, b));
            return(new Rgb((byte)r, (byte)g, (byte)b));
        }
        /// <summary>
        ///     The Working version of YCBCR to RGB conversion.
        ///     Transforms one value of YCBCR to RGB
        /// </summary>
        /// <param name="ycbcr">FROM</param>
        /// <param name="choice">TO</param>
        /// <returns></returns>
        private static Rgb YcbcrToRgbWorking(Ycbcr ycbcr, int choice) {
            int r = (int) (1.164*(ycbcr.Y - 16) + 1.596*(ycbcr.Cr - 128));
            int g = (int) (1.164*(ycbcr.Y - 16) - 0.813*(ycbcr.Cr - 128) - 0.392*(ycbcr.Cb - 128));
            int b = (int) (1.164*(ycbcr.Y - 16) + 2.017*(ycbcr.Cb - 128));

            r = Math.Max(0, Math.Min(255, r));
            g = Math.Max(0, Math.Min(255, g));
            b = Math.Max(0, Math.Min(255, b));
            return new Rgb((byte) r, (byte) g, (byte) b);
        }
예제 #3
0
 public bool Equals(Ycbcr ycbcr)
 {
     return((Math.Abs(Y - ycbcr.Y) < 0.01) && (Math.Abs(Cb - ycbcr.Cb) < 0.01) &&
            (Math.Abs(Cr - ycbcr.Cr) < 0.01));
 }
예제 #4
0
 public bool Equals(Ycbcr ycbcr) {
     return (Math.Abs(Y - ycbcr.Y) < 0.01) && (Math.Abs(Cb - ycbcr.Cb) < 0.01) &&
            (Math.Abs(Cr - ycbcr.Cr) < 0.01);
 }