private void copyStx(RasterDataNode sourceRaster, RasterDataNode targetRaster) { final Stx sourceStx = sourceRaster.getStx(); final Histogram sourceHistogram = sourceStx.getHistogram(); final Histogram targetHistogram = new Histogram( sourceStx.getHistogramBinCount(), sourceHistogram.getLowValue(0), sourceHistogram.getHighValue(0), 1); System.arraycopy( sourceHistogram.getBins(0), 0, targetHistogram.getBins(0), 0, sourceStx.getHistogramBinCount()); final Stx targetStx = new Stx( sourceStx.getMinimum(), sourceStx.getMaximum(), sourceStx.getMean(), sourceStx.getStandardDeviation(), sourceStx.getCoefficientOfVariation(), sourceStx.getEquivalentNumberOfLooks(), sourceStx.isLogHistogram(), sourceStx.isIntHistogram(), targetHistogram, sourceStx.getResolutionLevel()); targetRaster.setStx(targetStx); }
private void setStx(Stx stx) { if (stx != null) { HistogramPanelModel.HistogramConfig config = createHistogramConfig(); if (config == null) { return; } if (!model.hasStx(config)) { model.setStx(config, stx); } dataset = new XIntervalSeriesCollection(); final int[] binCounts = stx.getHistogramBins(); final RasterDataNode raster = getRaster(); final XIntervalSeries series = new XIntervalSeries(raster.getName()); final Histogram histogram = stx.getHistogram(); for (int i = 0; i < binCounts.length; i++) { final double xMin = histogram.getBinLowValue(0, i); final double xMax = i < binCounts.length - 1 ? histogram.getBinLowValue(0, i + 1) : histogram.getHighValue(0); series.add(xMin, xMin, xMax, binCounts[i]); } dataset.addSeries(series); } handleStxChange(); }
public static int[] compute(Histogram h) { int autoThreshold = 5000; double threshold = ((h.getTotals())[0]) / autoThreshold; int[] bins = h.getBins(0); int nBins = bins.length; int histogramMin = 0, histogramMax = 0; double[] pThreshold = h.getPTileThreshold(0.4); for (int loop = (int) pThreshold[0]; loop < nBins; loop++) if (bins[loop] > threshold) { histogramMin = loop; break; } for (int loop = nBins - 1; loop >= 0; loop--) if (bins[loop] > threshold) { histogramMax = loop; break; } if (histogramMax >= histogramMin) { int lowValue = (int) h.getLowValue(0); int min = lowValue + histogramMin; int max = lowValue + histogramMax; if (min == max) { min = (int) h.getLowValue(0); max = (int) h.getHighValue(0); } return new int[] {max - min, min + (int) ((max - min) / 2)}; } return null; }