/** * Computes the statistics. May be overridden. * This method belongs to preliminary API and may be removed or changed in the future. * * @param level The resolution level. * @param pm A progress monitor. * @return The statistics. * @since BEAM 4.5 */ protected Stx computeStxImpl(int level, ProgressMonitor pm) { return new StxFactory().withResolutionLevel(level).create(this, pm); }
@Override protected Stx computeStxImpl(int level, ProgressMonitor pm) { final IndexCoding indexCoding = getIndexCoding(); if (indexCoding == null) { return super.computeStxImpl(level, pm); } final int sampleCount = indexCoding.getSampleCount(); int minSample = Integer.MAX_VALUE; int maxSample = Integer.MIN_VALUE; for (int i = 0; i < sampleCount; i++) { final int sample = indexCoding.getSampleValue(i); minSample = Math.min(minSample, sample); maxSample = Math.max(maxSample, sample); } final int binCount = maxSample - minSample + 1; final double min = minSample; final double max = maxSample; return new StxFactory() .withResolutionLevel(level) .withHistogramBinCount(binCount) .withMinimum(min) .withMaximum(max).create(this, pm); }
.withIntHistogram(intHistogram) .withHistogramBins(frequencies) .withResolutionLevel(resolutionLevel) .create();
private static Stx createStx(Band band, Element bandStatisticsElem) { final Double minSample = getElemDouble(bandStatisticsElem, DimapProductConstants.TAG_STX_MIN); final Double maxSample = getElemDouble(bandStatisticsElem, DimapProductConstants.TAG_STX_MAX); final Double mean = getElemDouble(bandStatisticsElem, DimapProductConstants.TAG_STX_MEAN); final Double stdDev = getElemDouble(bandStatisticsElem, DimapProductConstants.TAG_STX_STDDEV); final Integer level = getElemInt(bandStatisticsElem, DimapProductConstants.TAG_STX_LEVEL); final int[] bins = getHistogramBins(bandStatisticsElem); boolean intHistogram = !ProductData.isFloatingPointType(band.getGeophysicalDataType()); if (minSample != null && maxSample != null) { return new StxFactory() .withMinimum(minSample) .withMaximum(maxSample) .withMean(mean) .withStandardDeviation(stdDev) .withIntHistogram(intHistogram) .withHistogramBins(bins == null ? new int[0] : bins) .withResolutionLevel(level).create(); } return null; }
private void setLogarithmicDisplay(final RasterDataNode raster, final boolean logarithmicDisplay) { final ImageInfoEditorModel model = imageInfoEditor.getModel(); if (logarithmicDisplay) { final StxFactory stxFactory = new StxFactory(); final Stx stx = stxFactory .withHistogramBinCount(raster.getStx().getHistogramBinCount()) .withLogHistogram(logarithmicDisplay) .withResolutionLevel(raster.getSourceImage().getModel().getLevelCount() - 1) .create(raster, ProgressMonitor.NULL); model.setDisplayProperties(raster.getName(), raster.getUnit(), stx, POW10_SCALING); } else { model.setDisplayProperties(raster.getName(), raster.getUnit(), raster.getStx(), Scaling.IDENTITY); } model.getImageInfo().setLogScaled(logarithmicDisplay); }