Esempio n. 1
0
        public static YiqImage FromRgb(RgbImage image)
        {
            int width  = image.Width;
            int height = image.Height;

            YiqImage result = new YiqImage(width, height);

            Matrix m = new Matrix(3, 3);

            m.Init(0.299, 0.587, 0.114, 0.596, -0.274, -0.321, 0.211, -0.526, 0.311);
            Matrix rbg = new Matrix(3, 1);

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    rbg.Init(image.R[x, y], image.G[x, y], image.B[x, y]);
                    Matrix yiq = m * rbg;
                    //result.YIQ[x, y] = new YIQ(yiq[0, 0], yiq[1, 0], yiq[2, 0]);
                    result.Y[x, y]  = yiq[0, 0];
                    result.Ic[x, y] = yiq[1, 0];
                    result.Qc[x, y] = yiq[2, 0];
                }
            }

            return(result);
        }
Esempio n. 2
0
        public static RgbImage FromYiq(YiqImage image)
        {
            int      width  = image.Width;
            int      height = image.Height;
            RgbImage result = new RgbImage(width, height);

            Matrix m = new Matrix(3, 3);

            m.Init(1, 0.956, 0.623, 1, -0.272, -0.648, 1, -1.105, 1.705);
            Matrix yiq = new Matrix(3, 1);

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    yiq.Init(image.Y[x, y], image.Ic[x, y], image.Qc[x, y]);
                    Matrix rbg = m * yiq;
                    double nr  = Normalize(rbg[0, 0]);
                    double ng  = Normalize(rbg[1, 0]);
                    double nb  = Normalize(rbg[2, 0]);
                    //result.RGB[x, y] = new RGB(nr, ng, nb);
                    result.R[x, y] = nr;
                    result.G[x, y] = ng;
                    result.B[x, y] = nb;
                }
            }

            return(result);
        }
Esempio n. 3
0
        public RgbImage GetRgb()
        {
            if (rgb == null)
            {
                rgb = RgbImage.FromBitmap(Image);
            }

            return(rgb);
        }
Esempio n. 4
0
        public async Task <RgbImage> GetRgbAsync()
        {
            if (rgb == null)
            {
                rgb = await RgbImage.FromBitmapAsync(Image);
            }

            return(rgb);
        }
Esempio n. 5
0
        public static RgbImage FromBitmap(Bitmap image)
        {
            int      width  = image.Width;
            int      height = image.Height;
            RgbImage result = new RgbImage(width, height);
            Color    pixel;

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    pixel = image.GetPixel(x, y);
                    //result.RGB[x, y] = new RGB(pixel.R, pixel.G, pixel.B);
                    result.R[x, y] = pixel.R;
                    result.G[x, y] = pixel.G;
                    result.B[x, y] = pixel.B;
                }
            }

            return(result);
        }
Esempio n. 6
0
 public static async Task <YiqImage> FromRgbAsync(RgbImage image)
 {
     return(await Task.Run(() => FromRgb(image)));
 }
Esempio n. 7
0
        public static YiqImage FromBitmap(Bitmap image)
        {
            RgbImage rgb = RgbImage.FromBitmap(image);

            return(YiqImage.FromRgb(rgb));
        }
Esempio n. 8
0
        public static async Task <YiqImage> FromBitmapAsync(Bitmap image)
        {
            RgbImage rgb = await RgbImage.FromBitmapAsync(image);

            return(await YiqImage.FromRgbAsync(rgb));
        }
Esempio n. 9
0
        public Bitmap ToBitmap()
        {
            RgbImage rgb = RgbImage.FromYiq(this);

            return(rgb.ToBitmap());
        }
Esempio n. 10
0
        public async Task <Bitmap> ToBitmapAsync()
        {
            RgbImage rgb = await RgbImage.FromYiqAsync(this);

            return(await rgb.ToBitmapAsync());
        }