值方图(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[], ); //image[0] 显示Blue,bin = 32
HistogramViewer.Show(loadImg, ); //显示所有信道 //2.使用HistogramBox,需要事先拉窗口中设定在窗口画面
this.histogramBox1.GenerateHistograms(loadImg, );
this.histogramBox1.Refresh(); //如果不刷新,图像显示一部分,没有自动缩放的功能
//this.histogramBox1.Show(); //如果不是刷新图像,有没有都可以
}
}
}
 

最新文章

  1. python logging模块详解[转]
  2. Async Programming - 1 async-await 糖的本质(1)
  3. python日常-int和float
  4. HTTPS是如何保证连接安全,你知道吗?
  5. Context上下文对象(抄书的)
  6. 删除链表中全部值为k的节点
  7. C语言遍历一个文件夹下面的所有文件
  8. cocos2d-x 3.0 final 中文显示
  9. 了解神奇的this
  10. (Problem 6)Sum square difference
  11. FZU 2113(数位dp)
  12. C语言课程设计 Win32应用程序
  13. mynotebook
  14. NOIP2015 D2T3 洛谷2680 BZOJ4326 运输计划 解题报告
  15. Python 标准类库 - 因特网协议与支持之socketserver
  16. 不转实体直接获取Json字符串中某个字段的值
  17. [转载]EF或LINQ 查询时使用IN并且根据列表自定义排序方法
  18. 线程同步Volatile与Synchronized(一)
  19. python 常库介绍及安装方法
  20. JS closure

热门文章

  1. 80X86寄存器详解&lt;转载&gt;
  2. hadoop集群安装规划
  3. matplotlib画子图时设置总标题
  4. nova instance启动中的同步与异步
  5. 多线程下使用Jedis
  6. python中的字符串的种种函数
  7. java: file/outputStream/InputStream 复制文件
  8. 解决:phantomjs helloworld.js报错: Can&#39;t open &#39;helloworld.js&#39;
  9. iTerm2 + Oh My Zsh
  10. LeetCode OJ:Count Complete Tree Nodes(完全二叉树的节点数目)