zoukankan      html  css  js  c++  java
  • EmguCV3.0几个控件的使用

    值方图(Histogram)是一种统计图数据,在影像处理中最常被用来统计一张图像或是感兴趣(ROI)区域的色彩分布,在这边本人使用的EmguCV 2.4.0版的内建值方图工具只有被包含在WinForm应用程序中至于要如何在WPF绘制值方图,那就要花比较多的步骤了,我们得自己画,这部分后续文章会在介绍

     
    所以接下来介绍的绘制环境是在C#的WinForm项目,
     
    步骤
     
    1.加入HistogramBox组件到WinForm
     
    点选上排工具 –> 选择工具箱 –> .Net Framework 组件中点选选择,找到EmguCV项目下的Emgu.CV.UI.dll并把dll加入后再次看一下.Net Framework 组件便会发现:
     

     
    2.在Form的设计工具箱中便会找到HistogramBox
     
     
    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;
    
    namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            
            /*
             * 第一对
             * HistogramBox The control that is used to display histogram(需要事先设计位置)
             * HistogramViewer A view for histogram(弹出新窗口,不需要事先设计)  
             * 第二对
             * ImageBox An image box is a user control that is similar to picture box, but display Emgu CV IImage and provides enhenced functionalities.
             * ImageViewer The Image viewer that display IImage
             * 第三对
             * MatrixBox A control that is used to visualize a matrix(用户控件) 
             * MatrixViewer A MatrixViewer that is used to visualize a matrix(弹出窗口)
             * 
             * 第四个
             * Operation An operation contains the MethodInfo and the methods parameters. It provides a way to invoke a specific method with the specific parameters.  
             * PanAndZoomPictureBox A picture box with pan and zoom functionality (可以事先图像的缩放) 
            */
            private void Form1_Load(object sender, EventArgs e)
            {
                Image<Bgr, byte> img = new Image<Bgr, byte>(@"C:a2.jpg");
                
                //Emgu.CV.UI.ImageBox 需要在窗口中设计
                this.imageBox1.Image = img;
                this.matrixBox1.Matrix = img;
                this.panAndZoomPictureBox1.Image = Image.FromFile(@"C:a1.jpg");
    
    
    
                //The Imageviewer 直接弹出新的窗口
                Image<Bgr, byte> loadImg = new Image<Bgr, byte>(@"C:a1.jpg");
                ImageViewer viewer = new ImageViewer(loadImg, "Loaded Image");
                viewer.Show(this);
               
                //1.使用HistogramViewer不需要事先拉到设计窗口中,他是弹出窗口,你只需要直接使用便可以
                HistogramViewer.Show(loadImg[0], 32); //image[0] 显示Blue,bin = 32
                HistogramViewer.Show(loadImg, 32); //显示所有信道
                
                //2.使用HistogramBox,需要事先拉窗口中设定在窗口画面
                this.histogramBox1.GenerateHistograms(loadImg, 32);
                this.histogramBox1.Refresh(); //如果不刷新,图像显示一部分,没有自动缩放的功能
                //this.histogramBox1.Show(); //如果不是刷新图像,有没有都可以
            }
        }
    }
     
  • 相关阅读:
    centos出现“FirewallD is not running”怎么办
    Centos7开放及查看端口
    phpRedis函数使用总结
    如何在Windows的PHPstudy中使用redis
    Redis命令操作详解
    不可不知 DDoS的攻击原理与防御方法
    DDoS 攻击与防御:从原理到实践
    ORM Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous
    PHP常用函数大全500+
    Linux彻底卸载Nginx
  • 原文地址:https://www.cnblogs.com/qqhfeng/p/5005141.html
Copyright © 2011-2022 走看看