Michael
Michael

Reputation: 13616

How to display EMGU histogram in chart control?

I have the following code example:

    //creating histogram using emgu cv c#
    //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);

After the histogram has been calculated, I want to dislay the result in a chart control.

Can someone provide ideas/sample code for implementing this? Thanks.

Upvotes: 0

Views: 3460

Answers (1)

Luca Del Tongo
Luca Del Tongo

Reputation: 2702

HistogramBox control let you automatically display image histogram.

Follow emgu instructions to get the whole list of control you can drag&drop on your form. Then it's just a couple of method calls.

histogramBox.GenerateHistograms(img,bin); //bin = 256 in your example

histogramBox2.Refresh();

Upvotes: 2

Related Questions