Esempio n. 1
0
 private void UpdateYUV(YUV yuv)
 {
     if (Convert.ToInt32(yuv.Y * 100) != (int)this.yUD.Value)
     {
         this.yUD.Value = Convert.ToInt32(yuv.Y * 100);
     }
     if (Convert.ToInt32((yuv.U + 0.436) * 100) != (int)this.uUD.Value)
     {
         this.uUD.Value = Convert.ToInt32((yuv.U + 0.436) * 100);
     }
     if (Convert.ToInt32((yuv.V + 0.615) * 100) != (int)this.vUD.Value)
     {
         this.vUD.Value = Convert.ToInt32((yuv.V + 0.615) * 100);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Converts RGB to YUV.
        /// </summary>
        /// <param name="red">red must be in [0, 255].</param>
        /// <param name="green">green must be in [0, 255].</param>
        /// <param name="blue">blue must be in [0, 255].</param>
        public static YUV RGBtoYUV(int red, int green, int blue)
        {
            YUV yuv = new YUV();

            // normalizes red/green/blue values
            double nRed   = (double)red / 255.0;
            double nGreen = (double)green / 255.0;
            double nBlue  = (double)blue / 255.0;

            // converts
            yuv.Y = 0.299 * nRed + 0.587 * nGreen + 0.114 * nBlue;
            yuv.U = -0.1471376975169300226 * nRed - 0.2888623024830699774 * nGreen + 0.436 * nBlue;
            yuv.V = 0.615 * nRed - 0.5149857346647646220 * nGreen - 0.1000142653352353780 * nBlue;

            return(yuv);
        }
Esempio n. 3
0
        /// <summary>
        /// Converts YUV to a .net Color.
        /// </summary>
        public static Color YUVtoColor(YUV yuv)
        {
            RGB rgb = YUVtoRGB(yuv);

            return(Color.FromArgb(rgb.Red, rgb.Green, rgb.Blue));
        }
Esempio n. 4
0
 /// <summary>
 /// Converts YUV to RGB.
 /// </summary>
 public static RGB YUVtoRGB(YUV yuv)
 {
     return(YUVtoRGB(yuv.Y, yuv.U, yuv.V));
 }