1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| 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 Emgu.CV;
using Emgu.CV.Structure;
namespace filtre
{public partial class Form1 : Form
{public Form1()
{InitializeComponent();}
private void button1_Click(object sender, EventArgs e)
{OpenFileDialog openfile = new OpenFileDialog();
if (openfile.ShowDialog() == DialogResult.OK)
{ Image<Bgr, Byte> img = new Image<Bgr, Byte>(openfile.FileName);//uploader l'image
Image<Gray, Byte> gray = img.Convert<Gray, Byte>().PyrDown().PyrUp();//conversion en niveau
//de gris et echantillonage
Gray cannyThreshold = new Gray(180);//définir le seuil
Gray cannyThresholdLinking = new Gray(120);//définir le seuil
Image<Gray, Byte> cannyEdges = gray.Canny(cannyThreshold, cannyThresholdLinking);//filtre de
//canny
pictureBox1.Image = cannyEdges.ToBitmap();
}}
private void pictureBox1_Click(object sender, EventArgs e)
{
}}} |
Partager