銳化:Sharpen()
對比延伸:ContrastStretch()
直方圖均化:HistogramEqualization()
Step1. 檔案 → 新增專案 → Windows Form 應用程式 → 拉物件 Form1.cs[設計] → 撰寫 Form1.cs
Step2. 方案總管 → 參考 → 右鍵加入參考 → 瀏灠(預設路徑) C:\Program Files (x86)\AForge.NET\Framework\Release → 加入參考
- AForge.Imaging.dll
- AForge.Imaging.Formats.dll
Step3. Windows Form 拉入需要工具:
- pictureBox × 2
- button × 4
- openFileDialog × 1
Step4. Coding
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.Formats; using AForge.Imaging.Filters; namespace TMV0 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } Bitmap imgone; //Sharpen private void button2_Click(object sender, EventArgs e) { Bitmap img; Sharpen filter = new Sharpen(); img = filter.Apply(imgone); pictureBox2.Image = img; } //Contrast Stretch private void button3_Click(object sender, EventArgs e) { Bitmap img; ContrastStretch filter = new ContrastStretch(); img = filter.Apply(imgone); pictureBox2.Image = img; } //Load Image private void button1_Click(object sender, EventArgs e) { openFileDialog1.Filter = "所有檔案(*.*)|*.*"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { imgone = ImageDecoder.DecodeFromFile(openFileDialog1.FileName); pictureBox1.Image = imgone; } } //Histogram Equalization private void button4_Click(object sender, EventArgs e) { Bitmap img; HistogramEqualization filter = new HistogramEqualization(); img = filter.Apply(imgone); pictureBox2.Image = img; } private void Form1_Load(object sender, EventArgs e) { } } }
沒有留言:
張貼留言