Esempio n. 1
0
        private ColorChannel ReduceChannel(ColorChannel channel, int factor)
        {
            int          reducedHeight = channel.GetHeight() / factor;
            int          reducedWidth  = channel.GetWidth() / factor;
            ColorChannel result        = new ColorChannel(reducedWidth, reducedHeight);

            for (int y = 0; y < reducedHeight; y++)
            {
                for (int x = 0; x < reducedWidth; x++)
                {
                    int sum = 0;
                    for (int blockY = y * factor; blockY < y * factor + factor; blockY++)
                    {
                        for (int blockX = x * factor; blockX < x * factor + factor; blockX++)
                        {
                            sum += (int)channel.GetPixel(blockX, blockY);
                        }
                    }

                    result.SetPixel(x, y, (int)Math.Round(sum / (double)(factor * factor)));
                }
            }

            return(result);
        }
Esempio n. 2
0
 private RGBImageBuilder(ColorChannel red)
 {
     _imageWidth  = red.GetWidth();
     _imageHeight = red.GetHeight();
     _red         = new ColorChannel(GetRealWidth(), GetRealHeight());
     _green       = new ColorChannel(GetRealWidth(), GetRealHeight());
     _blue        = new ColorChannel(GetRealWidth(), GetRealHeight());
     for (int i = 0; i < red.GetHeight(); i++)
     {
         for (int j = 0; j < red.GetWidth(); j++)
         {
             _red.SetPixel(j, i, red.GetPixel(j, i));
             _green.SetPixel(j, i, red.GetPixel(j, i));
             _blue.SetPixel(j, i, red.GetPixel(j, i));
         }
     }
 }