views:

478

answers:

1

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 ?

+2  A: 

Examples take from here:

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
thanks ! hope I'll make use of them
rantravee
You might need to check if the HistogramDataset is binning the data for you. Your array sounds like it is pre-binned.
Binary Nerd