如何创建直方图
我想在使用EMGU的C#程序中创建直方图。 EMGU中包含一个名为MCvHistogram的类,但我不知道如何使用它。
如果要使用EmguCV,则应使用DenseHistogram类。 我将告诉你基本用法:
// Create a grayscale image Image img = new Image(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(new Image[] { img }, true, null);
在DenseHistogram类中有许多其他常用方法,例如Back Projection
您可以使用以下代码段:
histogramBox.GenerateHistograms(image,bin); histogramBox2.Refresh();
它会自动创建图片的直方图。