Example #1
0
        private void btn_Sharpen_Click(object sender, EventArgs e)
        {
            var sw = new Stopwatch();

            var    initialImage       = (Bitmap)Image.FromFile(openFileDialog1.FileName);
            Bitmap reconstructedImage = (Bitmap)Image.FromFile(openFileDialog1.FileName);;

            if (pictureBox2.Image != null)
            {
                var brokenImage = (Bitmap)pictureBox2.Image;

                sw.Start();
                reconstructedImage = SharpenFilter.Sharpen(brokenImage, kernelSize);
                pictureBox3.Image  = reconstructedImage;
            }
            else
            {
                sw.Start();
                var brokenImage = SharpenFilter.Sharpen(initialImage, kernelSize);
                pictureBox2.Image = brokenImage;
            }

            sw.Stop();

            Filter = ImageHelper.Filter.Sharpen;
            //MessageBox.Show(sw.Elapsed.TotalSeconds.ToString());
            MessageBox.Show($"{ImageHelper.GetPSNR(initialImage, reconstructedImage)}");
        }
Example #2
0
        private void btn_Wiener_Click(object sender, EventArgs e)
        {
            var sw = new Stopwatch();

            var initialImage = (Bitmap)pictureBox1.Image;

            var greyImage = ImageHelper.ToGray(initialImage);

            pictureBox1.Image = greyImage;

            var brokenImage = new Bitmap(greyImage);

            switch (Filter)
            {
            case ImageHelper.Filter.Gauss:
                brokenImage = GaussianFilter.Blur(greyImage, kernelSize);
                break;

            case ImageHelper.Filter.Sharpen:
                brokenImage = SharpenFilter.Sharpen(greyImage, kernelSize);
                break;

            case ImageHelper.Filter.MotionLeftToRight:
                brokenImage = MotionFilter.Motion(greyImage, kernelSize, Direction.LeftToRight);
                break;

            case ImageHelper.Filter.MotionRightToLeft:
                brokenImage = MotionFilter.Motion(greyImage, kernelSize, Direction.RightToLeft);
                break;

            default:
                break;
            }

            pictureBox2.Image = brokenImage;

            var coreImage = ImageHelper.GetCoreImage(ImageHelper.ToGray(brokenImage), Filter);

            pictureBox3.Image = coreImage;

            sw.Start();
            var reconstructedImage = WienerFilter.Filter(ImageHelper.ToGray(brokenImage), Filter);

            pictureBox4.Image = reconstructedImage;

            sw.Stop();

            MessageBox.Show($"{ImageHelper.GetPSNR(greyImage, reconstructedImage)}");
            //MessageBox.Show(sw.Elapsed.TotalSeconds.ToString());
        }