private Color ConvertYuvToRgb(YuvColor yuvColor)
        {
            float r = yuvColor.Y + 1.14f * yuvColor.V;
            float g = yuvColor.Y - 0.395f * yuvColor.U - 0.581f * yuvColor.V;
            float b = yuvColor.Y + yuvColor.U * 2.033f;


            return(Color.FromArgb((int)(r * 255), (int)(g * 255), (int)(b * 255)));
        }
Example #2
0
        private void UpdateLabels(int x, int y)
        {
            positionX.Text = x.ToString();
            positionY.Text = y.ToString();

            byte      intensity     = Image.GetIntensity(x, y);
            Color     originalRgba  = Image.GetRgbaColor(x, y);
            Color     convertedRgba = Image.GetConvertedRgbaColor(x, y);
            HsvColor  hsv           = Image.GetHsvColor(x, y);
            CmykColor cmyk          = Image.GetCmykColor(x, y);
            YuvColor  yuv           = Image.GetYuvColor(x, y);

            intensityTextBlock.Text = intensity.ToString();

            originalRedTextBlock.Text   = originalRgba.R.ToString();
            originalGreenTextBlock.Text = originalRgba.G.ToString();
            originalBlueTextBlock.Text  = originalRgba.B.ToString();
            originalAlphaTextBlock.Text = originalRgba.A.ToString();

            convertedRedTextBlock.Text   = convertedRgba.R.ToString();
            convertedGreenTextBlock.Text = convertedRgba.G.ToString();
            convertedBlueTextBlock.Text  = convertedRgba.B.ToString();
            convertedAlphaTextBlock.Text = convertedRgba.A.ToString();

            hueTextBlock.Text        = String.Format("{0:0.#}", hsv.Hue);
            saturationTextBlock.Text = String.Format("{0:0.##}", hsv.Saturation);
            valueTextBlock.Text      = String.Format("{0:0.##}", hsv.Value);

            cyanTextBlock.Text    = String.Format("{0:0.##}", cmyk.Cyan);
            magentaTextBlock.Text = String.Format("{0:0.##}", cmyk.Magenta);
            yellowTextBlock.Text  = String.Format("{0:0.##}", cmyk.Yellow);
            blackTextBlock.Text   = String.Format("{0:0.##}", cmyk.Black);

            yTextBlock.Text = String.Format("{0:0.##}", yuv.Luma);
            uTextBlock.Text = String.Format("{0:0.##}", yuv.ColorDifferenceU);
            vTextBlock.Text = String.Format("{0:0.##}", yuv.ColorDifferenceV);
        }
 public static Color YuvToRgb(YuvColor yuvColor)
 {
     return(YuvToRgb(yuvColor.Luma, yuvColor.ColorDifferenceU, yuvColor.ColorDifferenceV));
 }
 private static YuvColor YuvToGreyscale(YuvColor yuvColor)
 {
     return(new YuvColor {
         Y = yuvColor.Y, U = 0, V = 0
     });
 }