如何创建直方图

Whi*_*arf 6 c# image histogram emgucv

我想在使用EMGU的C#程序中创建直方图.EMGU中包含一个名为MCvHistogram的类,但我不知道如何使用它.

Luc*_*ngo 11

如果要使用EmguCV,则应使用DenseHistogram类.我会告诉你基本用法:

  // 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);
Run Code Online (Sandbox Code Playgroud)

在DenseHistogram类中有许多其他常用方法,例如Back Projection

  • DenseHistogram是包装McvHistogram的托管类.您可以检查DenseHistogram类并检查它是否具有属性MCvHistogram.我的建议是当opencv功能已被包装在适当的托管类中时不使用cvinvoke ... (2认同)