很简单,一个对象使用apply()函数搞定。
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);
}
}
}