2015年12月10日 星期四

EmguCV C# 簡單的讀取圖片




此為簡單的讀取圖片,開啟過程也利用到了Resize 將圖片變形至400*400











以下為程式範例

 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Emgu.CV.CvEnum;
using Emgu.CV;   
using Emgu.CV.Structure;
namespace EmguCV_1
{
    
    public partial class Form1 : Form
    {
        private Image img;
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
           //開啟檔案
            OpenFileDialog filename = new OpenFileDialog();
            if (filename.ShowDialog() == DialogResult.OK)
            { 
            //將檔案路經存至Textbox1
                textBox1.Text = filename.FileName;
            }
        }
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            //將影像變型至400*400
            img = new Image(textBox1.Text).Resize(400, 400, Emgu.CV.CvEnum.Inter.Linear, true);
            imageBox1.Image = img;
        }
    }
}


沒有留言:

張貼留言