コード例 #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);
        }
コード例 #2
0
ファイル: RgbImage.cs プロジェクト: Dreuot/Trash
        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);
        }
コード例 #3
0
        public RgbImage GetRgb()
        {
            if (rgb == null)
            {
                rgb = RgbImage.FromBitmap(Image);
            }

            return(rgb);
        }
コード例 #4
0
        public async Task <RgbImage> GetRgbAsync()
        {
            if (rgb == null)
            {
                rgb = await RgbImage.FromBitmapAsync(Image);
            }

            return(rgb);
        }
コード例 #5
0
ファイル: RgbImage.cs プロジェクト: Dreuot/Trash
        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);
        }
コード例 #6
0
 public static async Task <YiqImage> FromRgbAsync(RgbImage image)
 {
     return(await Task.Run(() => FromRgb(image)));
 }
コード例 #7
0
        public static YiqImage FromBitmap(Bitmap image)
        {
            RgbImage rgb = RgbImage.FromBitmap(image);

            return(YiqImage.FromRgb(rgb));
        }
コード例 #8
0
        public static async Task <YiqImage> FromBitmapAsync(Bitmap image)
        {
            RgbImage rgb = await RgbImage.FromBitmapAsync(image);

            return(await YiqImage.FromRgbAsync(rgb));
        }
コード例 #9
0
        public Bitmap ToBitmap()
        {
            RgbImage rgb = RgbImage.FromYiq(this);

            return(rgb.ToBitmap());
        }
コード例 #10
0
        public async Task <Bitmap> ToBitmapAsync()
        {
            RgbImage rgb = await RgbImage.FromYiqAsync(this);

            return(await rgb.ToBitmapAsync());
        }