How to create a histogram

蹲街弑〆低调 提交于 2019-11-28 04:05:44

问题


I want to create a histogram within a C# program that uses EMGU. EMGU contains a class called MCvHistogram in it, but I don't know how to use it.


回答1:


You should use DenseHistogram class if you want to use EmguCV. I'll show you basic usage:

  // Create a grayscale image
  Image<Gray, Byte> img = new Image<Gray, byte>(400, 400);
  // Fill image with random values
  img.SetRandUniform(new MCvScalar(), new MCvScalar(255));
  // Create and initialize histogram
  DenseHistogram hist = new DenseHistogram(256, new RangeF(0.0f, 255.0f));
  // Histogram Computing
  hist.Calculate<Byte>(new Image<Gray, byte>[] { img }, true, null);

There are a lot of other common methods inside DenseHistogram class such as Back Projection




回答2:


You can use this code snippet:

histogramBox.GenerateHistograms(image,bin);               
histogramBox2.Refresh();

It will create a histogram of your picture automatically.



来源:https://stackoverflow.com/questions/4905893/how-to-create-a-histogram

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!