예제 #1
0
        private void InitGrayImage(Image <Gray, byte> image)
        {
            var width   = image.Width;
            var height  = image.Height;
            var imgData = image.Data;

            this.Data  = new List <Data2D>();
            this.Shape = new DataShape(1, width, height);
            var data2D = new Data2D(255, width, height);

            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    data2D.Add(imgData[i, j, 0], j, i);
                }
            }
            this.Data.Add(data2D);
        }
예제 #2
0
        private void InitBgrImage(Bitmap image)
        {
            var width  = image.Width;
            var height = image.Height;

            this.Data  = new List <Data2D>();
            this.Shape = new DataShape(3, width, height);

            for (int k = 0; k < 3; k++)
            {
                var data2D = new Data2D(255, width, height);

                for (int i = 0; i < height; i++)
                {
                    for (int j = 0; j < width; j++)
                    {
                        var color = image.GetPixel(j, i);
                        data2D.Add(k == 0 ? color.B : k == 1 ? color.G : color.R, j, i);
                    }
                }
                this.Data.Add(data2D);
            }
        }