示例#1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="image">The color image to construct this image from.  The values are calculated as (min(R,G,B) + max(R,G,B))/2</param>
        public unsafe MonochromeImage(RGBImage image)
        {
            int rows    = image.Rows;
            int columns = image.Columns;

            _handler = new IntegerArrayHandler(rows, columns, 1);
            fixed(int *dst = _handler.RawArray)
            {
                fixed(byte *src = image.RawArray)
                {
                    int * dstPtr = dst;
                    byte *srcPtr = src;
                    int   count  = rows * columns;

                    while (count-- > 0)
                    {
                        int R = *srcPtr++;
                        int G = *srcPtr++;
                        int B = *srcPtr++;

                        int min      = R < G ? (R < B ? R : (B < G ? B : G)) : (G < B ? G : B);
                        int max      = R > G ? (R > B ? R : (B > G ? B : G)) : (G > B ? G : B);
                        *   dstPtr++ = (min + max) >> 1;
                    }
                }
            }
        }
示例#2
0
 /// <summary>
 /// Default Constructor.
 /// </summary>
 public MonochromeImage()
 {
     _handler = new IntegerArrayHandler();
 }
示例#3
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="rows">Number of rows in the image</param>
 /// <param name="columns">Number of columns in the image</param>
 public MonochromeImage(int rows, int columns)
 {
     _handler = new IntegerArrayHandler(rows, columns, 1);
 }
示例#4
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public DistanceTransformImage()
 {
     _handler = new IntegerArrayHandler();
 }