public ImageBuffer CloneFormat()
 {
     ImageBuffer buffer = new ImageBuffer();
     buffer.Length = this.Length;
     buffer.Width = this.Width;
     buffer.Height = this.Height;
     buffer.Stride = this.Stride;
     return buffer;
 }
        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;
        }
        private void Process(ImageBuffer original)
        {
            box1.Display(original);

            ImageBuffer buffer = original.GrayScale();
            box2.Display(buffer);

            ImageBuffer buffer2 = buffer.CreepArea(20);
          
            box3.Display(buffer2);

            ImageBuffer buffer3 = buffer2.Kirsch();
            box4.Display(buffer3);
        }
 public static void Display(this PictureBox box, ImageBuffer buffer)
 {
     box.Image = buffer.ToBitmap();
 }
        public static ImageBuffer Filter(this ImageBuffer buffer, ImageBuffer filter)
        {
            // The filter image determines the intensity for each pixel R,G,B
            ImageBuffer output = buffer.CloneFormat();

            for (int k = 0; k < buffer.Bytes.Length; k += 4)
            {
                output.Bytes[k + 0] = (byte)(filter.Bytes[k + 0] * buffer.Bytes[k + 0] / 255);
                output.Bytes[k + 1] = (byte)(filter.Bytes[k + 1] * buffer.Bytes[k + 1] / 255);
                output.Bytes[k + 2] = (byte)(filter.Bytes[k + 2] * buffer.Bytes[k + 2] / 255);
                output.Bytes[k + 3] = buffer.Bytes[k + 3];
            }
            return output;

        }