Beispiel #1
0
        public ImageChannels Split(Bitmap img)
        {
            var red   = new float[img.Width, img.Height];
            var green = new float[img.Width, img.Height];
            var blue  = new float[img.Width, img.Height];

            for (var y = 0; y < img.Height; y++)
            {
                for (var x = 0; x < img.Width; x++)
                {
                    var clr = img.GetPixel(x, y);
                    red[x, y]   = clr.R;
                    green[x, y] = clr.G;
                    blue[x, y]  = clr.B;
                }
            }

            var splitImg = new ImageChannels();

            splitImg.SetAllValues(red, green, blue);
            splitImg.height = img.Height;
            splitImg.width  = img.Width;

            return(splitImg);
        }
Beispiel #2
0
        public Bitmap Merge(ImageChannels splitImg)
        {
            var bmp = new Bitmap(splitImg.width, splitImg.height);

            for (var y = 0; y < splitImg.height; y++)
            {
                for (var x = 0; x < splitImg.width; x++)
                {
                    var red   = (int)splitImg.channel_one[x, y];
                    var green = (int)splitImg.channel_two[x, y];
                    var blue  = (int)splitImg.channel_three[x, y];

                    var clr = Color.FromArgb(red, green, blue);
                    bmp.SetPixel(x, y, clr);
                }
            }

            return(bmp);
        }