/** Returns the histogram as an array of longs. */ public long[] getHistogram() { double[] hist = histogram(); long[] hist2 = new long[hist.length]; for (int i=0; i<hist.length; i++) hist2[i] = (long)hist[i]; return hist2; }
/** Returns the histogram as an array of longs. */ public long[] getHistogram() { double[] hist = histogram(); long[] hist2 = new long[hist.length]; for (int i=0; i<hist.length; i++) hist2[i] = (long)hist[i]; return hist2; }
/** Plots a histogram of this image using the specified number of bins and returns the PlotWindow. */ public PlotWindow plotHistogram(int bins) { ImageStatistics stats = getStatistics(AREA+MEAN+MODE+MIN_MAX, bins); Plot plot = new Plot("Hist_"+getTitle(), "Value", "Frequency"); plot.setColor("black", "#999999"); plot.setFont(new Font("SansSerif",Font.PLAIN,14)); double[] y = stats.histogram(); int n = y.length; double[] x = new double[n]; int bits = getBitDepth(); boolean eightBit = bits==8 || bits==24; double min = !eightBit?stats.min:0; for (int i=0; i<n; i++) x[i] = min+i*stats.binSize; plot.add("bar", x, y); if (bins!=256) plot.addLegend(bins+" bins", "auto"); if (eightBit) plot.setLimits(0,256,0,Double.NaN); return plot.show(); }
/** Plots a histogram of this image using the specified number of bins and returns the PlotWindow. */ public PlotWindow plotHistogram(int bins) { ImageStatistics stats = getStatistics(AREA+MEAN+MODE+MIN_MAX, bins); Plot plot = new Plot("Hist_"+getTitle(), "Value", "Frequency"); plot.setColor("black", "#999999"); plot.setFont(new Font("SansSerif",Font.PLAIN,14)); double[] y = stats.histogram(); int n = y.length; double[] x = new double[n]; int bits = getBitDepth(); boolean eightBit = bits==8 || bits==24; double min = !eightBit?stats.min:0; for (int i=0; i<n; i++) x[i] = min+i*stats.binSize; plot.add("bar", x, y); if (bins!=256) plot.addLegend(bins+" bins", "auto"); if (eightBit) plot.setLimits(0,256,0,Double.NaN); return plot.show(); }