/// <summary>
        /// Tries to build areas of similar coloured connected pixels
        /// (this Function assumes a grayscale image as imput(
        /// </summary>
        /// <param name="buffer"></param>
        /// <returns></returns>
        public static ImageBuffer CreepArea(this ImageBuffer buffer)
        {
            byte[] source = buffer.Bytes;

            ImageBuffer output = buffer.Clone();

            byte[] target = output.Bytes;

            for (int y = 0; y < output.Height - 1; y++)
            {
                for (int x = 1; x < output.Width - 1; x++)
                {
                    int ix = y * output.Stride + x * 4;

                    if (ix % 2 == 0)
                    {
                        int il = ix - 4;
                        ImageCreep.AverageOut(target, ix, il);
                    }
                    else
                    {
                        int ir = ix + 4;
                        ImageCreep.AverageOut(target, ix, ir);
                    }

                    int id = (y + 1) * output.Stride + x * 4;

                    ImageCreep.AverageOut(target, ix, id);
                }
            }

            return(output);
        }
        public static ImageBuffer CreepArea(this ImageBuffer buffer, int repeats)
        {
            ImageBuffer clone = buffer.Clone();

            for (int i = 0; i < repeats; i++)
            {
                clone = clone.CreepArea();
            }
            return(clone);
        }
        public static ImageBuffer SuperImpoze(this ImageBuffer image, ImageBuffer impoze)
        {
            ImageBuffer output = image.Clone();

            for (int k = 0; k < output.Bytes.Length; k += 4)
            {
                output.Bytes[k + 0] = ByteConversion.MinAtLevel(impoze.Bytes[k + 0], 1, output.Bytes[k + 0]);
                output.Bytes[k + 1] = ByteConversion.MinAtLevel(impoze.Bytes[k + 1], 1, output.Bytes[k + 1]);
                output.Bytes[k + 2] = ByteConversion.MinAtLevel(impoze.Bytes[k + 2], 1, output.Bytes[k + 2]);
                output.Bytes[k + 3] = 255;
            }
            return(output);
        }
        public static ImageBuffer MapAndAverage(this ImageBuffer buffer, int x, int y)
        {
            var map   = buffer.CloneFormat().Fill(Color.FromArgb(0));
            var work  = new List <Coordinate>();
            var clone = buffer.Clone();

            var origin = new Coordinate(x, y);

            int i = map.Index(origin);

            map.Bytes[i] = 1;


            int j = map.Index(origin.Right());

            return(map);
        }
 public static ImageBuffer DoeIets(this ImageBuffer input)
 {
     return(input.Clone());
 }