Exemple #1
0
        private void btn_Wiener_Click(object sender, EventArgs e)
        {
            var initialImage = (Bitmap)Image.FromFile(openFileDialog1.FileName);

            var filteredImage = WienerFilter.Filter(initialImage);

            pictureBox2.Image    = filteredImage;
            pictureBox2.SizeMode = PictureBoxSizeMode.StretchImage;
        }
Exemple #2
0
        public void TestWienerFilteringNoNoise()
        {
            var filter = new WienerFilter(3, 0.1);

            var input    = new[] { 5, 4, 6, 2, 1f };
            var expected = new[] { 4.95714286f, 4.15f, 5.925f, 2.02142857f, 1 };

            var filtered = filter.ApplyTo(new DiscreteSignal(1, input));

            Assert.That(filtered.Samples, Is.EqualTo(expected).Within(1e-5));
        }
Exemple #3
0
        public void TestWienerFilteringBigNoise()
        {
            var filter = new WienerFilter(3, 1000);

            var input    = new[] { 5, 4, 6, 2, 1f };
            var expected = new[] { 3, 5, 4, 3, 1f };

            var filtered = filter.ApplyTo(new DiscreteSignal(1, input));

            Assert.That(filtered.Samples, Is.EqualTo(expected).Within(1e-10));
        }
Exemple #4
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());
        }