9

I'm trying to use JfreeChart to create a chart for the histogram of an image , but I don't fully understand how to provide the input data for the histogram .The function I am suppose to use is this:

addSeries(java.lang.Comparable key, double[] values, int bins) 

I find that documentation is really unclear. I have a 256-element array filled with the number of pixels of each intensity which I want to be able to use as an input, but I don't know how. Has someone encountered this problem before ?

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
klaus johan
  • 4,370
  • 10
  • 39
  • 56

1 Answers1

8

Examples loading data into a JFreeChart HistogramDataset:

HistogramDataset dataset = new HistogramDataset();
dataset.setType(HistogramType.RELATIVE_FREQUENCY);
dataset.addSeries("H1", double[], 20);

HistogramDataset dataset = new HistogramDataset();
double[] values = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0};
dataset.addSeries("H1", values, 10, 0.0, 10.0);
Binary Nerd
  • 13,872
  • 4
  • 42
  • 44