private void computeStatistic(String regionName, StxOpMapping stxOpsMapping, Band band, Shape roiShape, MultiLevelImage roiImage) { final SummaryStxOp summaryStxOp = stxOpsMapping.getSummaryOp(regionName); StxFactory.accumulate(band, 0, roiImage, roiShape, summaryStxOp, SubProgressMonitor.create(pm, 50)); final double minimum = summaryStxOp.getMinimum(); final double maximum = summaryStxOp.getMaximum(); final HistogramStxOp histogramStxOp = stxOpsMapping.getHistogramOp(regionName, minimum, maximum, band); StxFactory.accumulate(band, 0, roiImage, roiShape, histogramStxOp, SubProgressMonitor.create(pm, 50)); }
for (int i = 0; i < filteredRasters.length; i++) { final RasterDataNode rasterDataNode = filteredRasters[i]; accumulate(rasterDataNode, level, roiImages[i], roiShapes[i], meanOp, SubProgressMonitor.create(pm, 50)); for (int i = 0; i < filteredRasters.length; i++) { final RasterDataNode rasterDataNode = filteredRasters[i]; accumulate(rasterDataNode, level, roiImages[i], roiShapes[i], histogramOp, SubProgressMonitor.create(pm, 50));
public static void accumulate(RasterDataNode rasterDataNode, int level, RenderedImage roiImage, Shape roiShape, StxOp op, ProgressMonitor pm) { Assert.notNull(rasterDataNode, "raster"); Assert.argument(level >= 0, "level"); Assert.argument(roiImage == null || level == 0, "level"); Assert.notNull(pm, "pm"); final PlanarImage dataImage = ImageManager.getInstance().getGeophysicalImage(rasterDataNode, level); if (dataImage.getSampleModel().getNumBands() != 1) { throw new IllegalStateException("dataImage.sampleModel.numBands != 1"); } PlanarImage maskImage = getEffectiveMaskImage(rasterDataNode, level, roiImage); Shape maskShape = getEffectiveShape(rasterDataNode, roiShape); accumulate(op, dataImage, maskImage, maskShape, pm); }
@Test public void testThatAccumulateWithSummaryStxOpGetsTheRightMinMax() { //preparation final Band testBand = createFloatTestBand(10, 10, 20, 60); final SummaryStxOp stxOp = new SummaryStxOp(); //execution StxFactory.accumulate(testBand, 0, null, null, stxOp, ProgressMonitor.NULL); //verification assertEquals(20, stxOp.getMinimum(), 1e-44); assertEquals(60, stxOp.getMaximum(), 1e-44); assertEquals(40, stxOp.getMean(), 1e-7); final double variance = 137.4009443244; assertEquals(variance, stxOp.getVariance(), 1e-7); assertEquals(Math.sqrt(variance), stxOp.getStandardDeviation(), 1e-7); }