Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

histogram in jfreechart

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 ?

like image 635
klaus johan Avatar asked Feb 06 '10 21:02

klaus johan


1 Answers

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);
like image 114
Binary Nerd Avatar answered Nov 10 '22 21:11

Binary Nerd