Ejemplo n.º 1
0
        public static Bitmap FastGuidedFilterEnchacement(Bitmap bmp)
        {
            var fastGuidedFilter = new FastGuidedFilter
            {
                KernelSize       = 16,
                Epsilon          = 0.16f,
                SubSamplingRatio = 0.25f,
                OverlayImage     = (Bitmap)bmp.Clone()
            };

            var guidedImage = fastGuidedFilter.Apply(bmp);

            var subtracted = new Subtract(guidedImage).Apply(fastGuidedFilter.OverlayImage);

            guidedImage.Dispose();

            //var mul = 100;
            //var Multiply = FastGuidedFilter.GetFilledImage(
            //    subtracted.Width, subtracted.Height,
            //    subtracted.PixelFormat, Color.FromArgb(mul, mul, mul));

            //new Multiply(Multiply).ApplyInPlace(subtracted);
            //Multiply.Dispose();

            new Add(subtracted).ApplyInPlace(fastGuidedFilter.OverlayImage);
            subtracted.Dispose();

            return(AForge.Imaging.Image.Convert16bppTo8bpp(fastGuidedFilter.OverlayImage));
        }
Ejemplo n.º 2
0
        private void button3_Click(object sender, EventArgs e)
        {
            button2_Click(sender, e);

            _elapsedTime.Restart();

            using (var bmp = AForge.Imaging.Image.Convert8bppTo16bpp((Bitmap)pictureBox2.Image))
            {
                var fastGuidedFilter = new FastGuidedFilter
                {
                    KernelSize       = 16,
                    Epsilon          = 0.16f,
                    SubSamplingRatio = 0.25f,
                    OverlayImage     = (Bitmap)bmp.Clone()
                };

                var guidedImage = fastGuidedFilter.Apply(bmp);

                var subtracted = new Subtract(guidedImage).Apply(fastGuidedFilter.OverlayImage);
                guidedImage.Dispose();

                //var mul = 100;
                //var Multiply = FastGuidedFilter.GetFilledImage(
                //    subtracted.Width, subtracted.Height,
                //    subtracted.PixelFormat, Color.FromArgb(mul, mul, mul));

                //new Multiply(Multiply).ApplyInPlace(subtracted);
                //Multiply.Dispose();

                new Add(subtracted).ApplyInPlace(fastGuidedFilter.OverlayImage);
                subtracted.Dispose();

                pictureBox2.Image?.Dispose();

                pictureBox2.Image = AForge.Imaging.Image.Convert16bppTo8bpp(fastGuidedFilter.OverlayImage);

                fastGuidedFilter.OverlayImage.Dispose();
            }

            _elapsedTime.Stop();
            Text = $"{_elapsedTime.Elapsed.Milliseconds} (ms)";
        }