コード例 #1
0
        /// <summary>
        /// Transform to a grayscale image
        /// by building the average of all channels
        /// </summary>
        /// <returns></returns>
        public OneChannelBitmap GetGrayscale()
        {
            var res = new OneChannelBitmap(Width, Height);

            for (int i = 0; i < Width; i++)
            {
                for (int j = 0; j < Height; j++)
                {
                    res.Channel[i, j] = Avg(_r.Channel[i, j], _g.Channel[i, j], _r.Channel[i, j]);
                }
            }
            return(res);
        }
コード例 #2
0
        /// <summary>
        /// Adding two channels
        /// </summary>
        /// <remarks>Overflow protection</remarks>
        /// <param name="a1"></param>
        /// <param name="a2"></param>
        /// <returns></returns>
        public static OneChannelBitmap operator +(OneChannelBitmap a1, OneChannelBitmap a2)
        {
            var width  = a1.Width;
            var height = a1.Height;
            var res    = new OneChannelBitmap(width, height);

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    res._c[i, j] = Sum(a1._c[i, j], a2._c[i, j]);
                }
            }
            return(res);
        }
コード例 #3
0
 /// <summary>
 /// Create a bitmap from Channels
 /// </summary>
 /// <param name="r">Red source</param>
 /// <param name="g">Green source</param>
 /// <param name="b">Blue source</param>
 public ThreeChannelBitmap(OneChannelBitmap r, OneChannelBitmap g, OneChannelBitmap b)
 {
     _r = r;
     _g = g;
     _b = b;
 }
コード例 #4
0
 /// <summary>
 /// Create a bitmap from an byte array
 /// </summary>
 /// <param name="r">Red source</param>
 /// <param name="g">Green source</param>
 /// <param name="b">Blue source</param>
 public ThreeChannelBitmap(byte[,] r, byte[,] g, byte[,] b)
 {
     _r = new OneChannelBitmap(r);
     _g = new OneChannelBitmap(g);
     _b = new OneChannelBitmap(b);
 }
コード例 #5
0
 /// <summary>
 /// Creates an empty bitmap with the desired size
 /// </summary>
 /// <param name="width">desired width</param>
 /// <param name="height">desired height</param>
 public ThreeChannelBitmap(int width, int height)
 {
     _r = new OneChannelBitmap(width, height);
     _g = new OneChannelBitmap(width, height);
     _b = new OneChannelBitmap(width, height);
 }
コード例 #6
0
 /// <summary>
 /// Create a new bitmap with size 0,0
 /// </summary>
 public ThreeChannelBitmap()
 {
     _r = new OneChannelBitmap();
     _g = new OneChannelBitmap();
     _b = new OneChannelBitmap();
 }