@Test public void testSubtract() { double[] constants = new double[] {18}; GridCoverage sourceCoverage = SST; GridCoverage targetCoverage = (GridCoverage) processor.subtract(sourceCoverage, constants); RenderedImage sourceImage = sourceCoverage.getRenderableImage(0, 1).createDefaultRendering(); RenderedImage targetImage = targetCoverage.getRenderableImage(0, 1).createDefaultRendering(); Raster sourceRaster = sourceImage.getData(); Raster targetRaster = targetImage.getData(); assertNotSame(sourceCoverage, targetCoverage); assertNotSame(sourceImage, targetImage); assertNotSame(sourceRaster, targetRaster); assertSame( sourceCoverage.getCoordinateReferenceSystem(), targetCoverage.getCoordinateReferenceSystem()); assertEquals(sourceCoverage.getEnvelope(), targetCoverage.getEnvelope()); assertEquals(sourceCoverage.getGridGeometry(), targetCoverage.getGridGeometry()); assertEquals(sourceRaster.getMinX(), targetRaster.getMinX()); assertEquals(sourceRaster.getMinY(), targetRaster.getMinY()); assertEquals(sourceRaster.getWidth(), targetRaster.getWidth()); assertEquals(sourceRaster.getHeight(), targetRaster.getHeight()); assertEquals(0, sourceRaster.getMinX()); assertEquals(0, sourceRaster.getMinY()); assertEquals( JAIExt.getOperationName("SubtractConst"), ((OperationNode) targetImage).getOperationName()); final boolean medialib = TestData.isMediaLibAvailable(); float difference; float s; float t; for (int y = sourceRaster.getHeight(); --y >= 0; ) { for (int x = sourceRaster.getWidth(); --x >= 0; ) { s = sourceRaster.getSampleFloat(x, y, 0); t = targetRaster.getSampleFloat(x, y, 0); if (Float.isNaN(s)) { if (medialib) { assertTrue(Float.isNaN(t)); } } else { difference = s - (float) constants[0]; if (difference < 0) { assertEquals(0, t, 1E-3f); } else if (difference > (255 - constants[0])) { assertEquals(255, t, 1E-3f); } else { assertEquals(difference, t, 1E-3f); } } } } if (SHOW) { show(targetCoverage); } }
public Coverage subtract(final Coverage source, final double[] constants) throws CoverageProcessingException { return doOperation("SubtractConst", source, "constants", constants); }
Operations { public Coverage subtract(final Coverage source, final double[] constants) throws CoverageProcessingException { return doOperation("SubtractConst", source, "constants", constants); } }
Operations { public Coverage subtract(final Coverage source, final double[] constants) throws CoverageProcessingException { return doOperation("SubtractConst", source, "constants", constants); } Operations(final RenderingHints hints); }
Operations { public Coverage subtract(final Coverage source, final double[] constants) throws CoverageProcessingException { return doOperation("SubtractConst", source, "constants", constants); } Operations(final RenderingHints hints); Coverage add(final Coverage source, final double[] constants); Coverage add(final Coverage source0, final Coverage source1); Coverage multiply(final Coverage source0, final Coverage source1); Coverage subtract(final Coverage source, final double[] constants); Coverage subtractFrom(final Coverage source, final double[] constants); Coverage multiply(final Coverage source, final double[] constants); Coverage divideBy(final Coverage source, final double[] constants); Coverage rescale(final Coverage source, final double[] constants, final double[] offsets); Coverage invert(final Coverage source); Coverage absolute(final Coverage source); Coverage log(final Coverage source); Coverage exp(final Coverage source); Coverage extrema(final Coverage source); GridCoverage nodataFilter(final GridCoverage source); GridCoverage nodataFilter(
            final GridCoverage source, final int padding, final int validityThreshold); GridCoverage interpolate(final GridCoverage source, final String type); GridCoverage interpolate(final GridCoverage source, final Interpolation type); GridCoverage interpolate(final GridCoverage source, final Interpolation[] types); Coverage selectSampleDimension(final Coverage source, final int[] sampleDimensions); Coverage resample(final Coverage source, final CoordinateReferenceSystem crs); Coverage resample(
            final GridCoverage source,
            final Envelope envelope,
            final Interpolation interpolationType); Coverage resample(
            final GridCoverage source,
            final CoordinateReferenceSystem crs,
            final GridGeometry gridGeometry,
            final Interpolation interpolationType); Coverage resample(
            final GridCoverage source,
            final CoordinateReferenceSystem crs,
            final GridGeometry gridGeometry,
            final Interpolation interpolationType,
            final double[] backgroundValues); Coverage crop(final Coverage source, final Envelope envelope); Coverage crop(final Coverage source, final Geometry roi); GridCoverage scale(
            final GridCoverage source,
            final double xScale,
            final double yScale,
            final double xTrans,
            final double yTrans); GridCoverage warp(final GridCoverage source, final Warp warp); GridCoverage affine(
            final GridCoverage source,
            final AffineTransform transform,
            final Interpolation interpolation,
            final double[] noDataValues); GridCoverage scale(
            final GridCoverage source,
            final double xScale,
            final double yScale,
            final double xTrans,
            final double yTrans,
            final Interpolation interpolation); GridCoverage warp(
            final GridCoverage source, final Warp warp, final Interpolation interpolation); GridCoverage subsampleAverage(
            final GridCoverage source, final double scaleX, final double scaleY); GridCoverage filteredSubsample(final GridCoverage source); GridCoverage filteredSubsample(
            final GridCoverage source, final int scaleX, final int scaleY, final float[] qsFilter); GridCoverage filteredSubsample(
            final GridCoverage source,
            final int scaleX,
            final int scaleY,
            final float[] qsFilter,
            final Interpolation interpolation); }
Operations { public Coverage subtract(final Coverage source, final double[] constants) throws CoverageProcessingException { return doOperation("SubtractConst", source, "constants", constants); } Operations(final RenderingHints hints); Coverage add(final Coverage source, final double[] constants); Coverage add(final Coverage source0, final Coverage source1); Coverage multiply(final Coverage source0, final Coverage source1); Coverage subtract(final Coverage source, final double[] constants); Coverage subtractFrom(final Coverage source, final double[] constants); Coverage multiply(final Coverage source, final double[] constants); Coverage divideBy(final Coverage source, final double[] constants); Coverage rescale(final Coverage source, final double[] constants, final double[] offsets); Coverage invert(final Coverage source); Coverage absolute(final Coverage source); Coverage log(final Coverage source); Coverage exp(final Coverage source); Coverage extrema(final Coverage source); GridCoverage nodataFilter(final GridCoverage source); GridCoverage nodataFilter(
            final GridCoverage source, final int padding, final int validityThreshold); GridCoverage interpolate(final GridCoverage source, final String type); GridCoverage interpolate(final GridCoverage source, final Interpolation type); GridCoverage interpolate(final GridCoverage source, final Interpolation[] types); Coverage selectSampleDimension(final Coverage source, final int[] sampleDimensions); Coverage resample(final Coverage source, final CoordinateReferenceSystem crs); Coverage resample(
            final GridCoverage source,
            final Envelope envelope,
            final Interpolation interpolationType); Coverage resample(
            final GridCoverage source,
            final CoordinateReferenceSystem crs,
            final GridGeometry gridGeometry,
            final Interpolation interpolationType); Coverage resample(
            final GridCoverage source,
            final CoordinateReferenceSystem crs,
            final GridGeometry gridGeometry,
            final Interpolation interpolationType,
            final double[] backgroundValues); Coverage crop(final Coverage source, final Envelope envelope); Coverage crop(final Coverage source, final Geometry roi); GridCoverage scale(
            final GridCoverage source,
            final double xScale,
            final double yScale,
            final double xTrans,
            final double yTrans); GridCoverage warp(final GridCoverage source, final Warp warp); GridCoverage affine(
            final GridCoverage source,
            final AffineTransform transform,
            final Interpolation interpolation,
            final double[] noDataValues); GridCoverage scale(
            final GridCoverage source,
            final double xScale,
            final double yScale,
            final double xTrans,
            final double yTrans,
            final Interpolation interpolation); GridCoverage warp(
            final GridCoverage source, final Warp warp, final Interpolation interpolation); GridCoverage subsampleAverage(
            final GridCoverage source, final double scaleX, final double scaleY); GridCoverage filteredSubsample(final GridCoverage source); GridCoverage filteredSubsample(
            final GridCoverage source, final int scaleX, final int scaleY, final float[] qsFilter); GridCoverage filteredSubsample(
            final GridCoverage source,
            final int scaleX,
            final int scaleY,
            final float[] qsFilter,
            final Interpolation interpolation); static final Operations DEFAULT; }