OpenCV trên C# - EmguCV Bài 1: LOAD FILE ẢNH VÀ HIỂN THỊ SANG B,R,G AND GRAY IMAGE
Tạo project C# với EmguCV
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
| 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;using Emgu.CV.UI;using Emgu.Util;namespace EmguCV{public partial class Form1 : Form{Image<Bgr, Byte> img;void color(Image<Bgr, Byte> src, int channel1, int channel2){for (int i = 0; i < src.Rows; i++){for (int j = 0; j < src.Cols; j++){src.Data[i, j, channel1] = 0;src.Data[i, j, channel2] = 0;}}}public Form1(){InitializeComponent();}private void Form1_Load(object sender, EventArgs e){}private void button1_Click(object sender, EventArgs e){OpenFileDialog Openfile = new OpenFileDialog();if (Openfile.ShowDialog() == DialogResult.OK){img = new Image<Bgr, byte>(Openfile.FileName);if (img.Size.Width >= 1200 && img.Size.Height >= 600){img = img.Resize(0.7,Emgu.CV.CvEnum.INTER.CV_INTER_LINEAR);}pictureBox1.Image = img.ToBitmap();button1.Location = new Point(img.Cols / 6, img.Rows + 10);exit_bt.Location = new Point(2 * img.Cols / 3, img.Rows + 10);pictureBox1.Size = img.Size;blue_bt.Location = new Point(img.Cols + 40, 10);red_bt.Location = new Point(img.Cols + 40, 80);green_bt.Location = new Point(img.Cols + 40, 150);gray_bt.Location = new Point(img.Cols + 40, 220);ori_bt.Location = new Point(img.Cols + 40, 290);//Image My_Image = Image.FromFile(Openfile.FileName);//pictureBox1.Image = My_Image}}private void pictureBox1_Click(object sender, EventArgs e){}private void button2_Click(object sender, EventArgs e){Image<Bgr, Byte> blue_img;blue_img = img.Clone();color(blue_img, 1, 2); ;pictureBox1.Image = blue_img.ToBitmap();}private void button3_Click(object sender, EventArgs e){Image<Bgr, Byte> red_img;red_img = img.Clone();color(red_img, 0, 1);pictureBox1.Image = red_img.ToBitmap();}private void button5_Click(object sender, EventArgs e){Image<Gray, Byte> gray_image = img.Convert<Gray, byte>();pictureBox1.Image = gray_image.ToBitmap();}private void button4_Click(object sender, EventArgs e){Image<Bgr, Byte> green_img;green_img = img.Clone();color(green_img, 0, 2);pictureBox1.Image = green_img.ToBitmap();}private void button2_Click_1(object sender, EventArgs e){pictureBox1.Image = img.ToBitmap();}private void exit_bt_Click(object sender, EventArgs e){Application.Exit();}}} |
OpenCV trên C# - EmguCV Bài 1: LOAD FILE ẢNH VÀ HIỂN THỊ SANG B,R,G AND GRAY IMAGE
Reviewed by Jacky
on
tháng 10 07, 2018
Rating:
Reviewed by Jacky
on
tháng 10 07, 2018
Rating:

Không có nhận xét nào: