AForge.NET Framework2.25--图像视觉处理学习(四)---图像平滑和滤波

时间:2024-03-24 18:15:27

很简单,一个对象使用apply()函数搞定。

AForge.NET Framework2.25--图像视觉处理学习(四)---图像平滑和滤波

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AForge.Imaging;
using AForge.Imaging.Filters;
using AForge;


namespace aforge_test
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        private void button1_Click(object sender, EventArgs e)  //中值滤波
        {
            Bitmap a = new Bitmap("adaptive_smooth.png");
            pictureBox1.Image = a;
            Median luobi = new Median(5);
           pictureBox2.Image= luobi.Apply(a);
        }


        private void button2_Click(object sender, EventArgs e) //自适应滤波
        {
            Bitmap a = new Bitmap("adaptive_smooth.png");
            pictureBox1.Image = a;
            AdaptiveSmoothing luobi = new AdaptiveSmoothing(20);
            pictureBox2.Image = luobi.Apply(a);
        }


        private void button3_Click(object sender, EventArgs e)//双边滤波 其中参数都有默认值
        {
            Bitmap a = new Bitmap("adaptive_smooth.png");
            pictureBox1.Image = a;
            BilateralSmoothing luobi = new BilateralSmoothing();
            pictureBox2.Image = luobi.Apply(a);
        }


        private void button4_Click(object sender, EventArgs e)
        {
            Bitmap a = new Bitmap("adaptive_smooth.png");
            pictureBox1.Image = a;
            ConservativeSmoothing luobi = new ConservativeSmoothing(7);
            pictureBox2.Image = luobi.Apply(a);
        }


        private void button5_Click(object sender, EventArgs e)
        {
            Bitmap a = new Bitmap("adaptive_smooth.png");
            pictureBox1.Image = a;
            Mean luobi = new Mean();
            pictureBox2.Image = luobi.Apply(a);
        }
    }
}