final double[] minimums = (double[]) result.getProperty(GT_SYNTHETIC_PROPERTY_MIN); if (minimums != null) synthProp.put(GT_SYNTHETIC_PROPERTY_MIN, minimums); final double[] maximums = (double[]) result.getProperty(GT_SYNTHETIC_PROPERTY_MAX); if (maximums != null) synthProp.put(GT_SYNTHETIC_PROPERTY_MAX, maximums); final double[] means = (double[]) result.getProperty(GT_SYNTHETIC_PROPERTY_MEAN); if (means != null) synthProp.put(GT_SYNTHETIC_PROPERTY_MEAN, means); final double[] var = (double[]) result.getProperty(GT_SYNTHETIC_PROPERTY_VAR); if (var != null) synthProp.put(GT_SYNTHETIC_PROPERTY_VAR, var); final double[] sdev = (double[]) result.getProperty(GT_SYNTHETIC_PROPERTY_SDEV); if (sdev != null) synthProp.put(GT_SYNTHETIC_PROPERTY_SDEV, sdev); final double[] range = (double[]) result.getProperty(GT_SYNTHETIC_PROPERTY_RANGE); if (range != null) synthProp.put(GT_SYNTHETIC_PROPERTY_RANGE, range); final double[] median = (double[]) result.getProperty(GT_SYNTHETIC_PROPERTY_MEDIAN); if (median != null) synthProp.put(GT_SYNTHETIC_PROPERTY_MEDIAN, median); final double[] approx_median = (double[]) result.getProperty(GT_SYNTHETIC_PROPERTY_APPROX_MEDIAN); if (approx_median != null) synthProp.put(GT_SYNTHETIC_PROPERTY_APPROX_MEDIAN, approx_median); final double[] sum = (double[]) result.getProperty(GT_SYNTHETIC_PROPERTY_SUM); if (sum != null) synthProp.put(GT_SYNTHETIC_PROPERTY_SUM, sum);
((Statistics[][]) result.getProperty(Statistics.STATS_PROPERTY)); (double[]) result.getProperty(GT_SYNTHETIC_PROPERTY_MAXIMUM); final double[] minimums = (double[]) result.getProperty(GT_SYNTHETIC_PROPERTY_MINIMUM); Object property = result.getProperty(GT_SYNTHETIC_PROPERTY_MIN_LOCATIONS); if ((property instanceof List[])) synthProp.put(GT_SYNTHETIC_PROPERTY_MIN_LOCATIONS, (List<int[]>[]) property); property = result.getProperty(GT_SYNTHETIC_PROPERTY_MAX_LOCATIONS); if ((property instanceof List[])) synthProp.put(GT_SYNTHETIC_PROPERTY_MAX_LOCATIONS, (List<int[]>[]) property);
synthProp, CoverageUtilities.getNoDataProperty(source)); Object results = result.getProperty(GT_SYNTHETIC_PROPERTY_ZONALSTATS);
((Statistics[][]) result.getProperty(Statistics.STATS_PROPERTY)); result.getProperty(GT_SYNTHETIC_PROPERTY_HISTOGRAM);
/** * Test transparency is preserved when applying an RGB ChannelSelect and ContrastEnhancement * style to an imageMosaic with Transparent Footprint setting. */ @Test public void testTransparentFootprintWithContrastEnhancementInChannelSelect() throws IOException, NoSuchAuthorityCodeException, FactoryException { File mosaicDirectory = prepareDirectory("footprintCECS"); GridCoverage2D gc = readCoverage(mosaicDirectory, FootprintBehavior.Transparent, null); RenderedImage ri = gc.getRenderedImage(); RenderedOp extrema = ExtremaDescriptor.create(ri, null, 1, 1, false, 1, null); double[] minimum = (double[]) extrema.getProperty("minimum"); double[] maximum = (double[]) extrema.getProperty("maximum"); // read values, not stretched, alpha is present assertArrayEquals(new double[] {0, 0, 0, 0}, minimum, 1E-6); assertArrayEquals(new double[] {54, 54, 54, 255}, maximum, 1E-6); GridCoverage2D output = (GridCoverage2D) symbolizeRaster(gc, "ce_cs.sld"); ri = output.getRenderedImage(); // Assert the alpha band has been preserved, even with a CS+CE SLD in place assertHasAlpha(ri); extrema = ExtremaDescriptor.create(ri, null, 1, 1, false, 1, null); minimum = (double[]) extrema.getProperty("minimum"); maximum = (double[]) extrema.getProperty("maximum"); // values are stretched assertArrayEquals(new double[] {0, 0, 0, 0}, minimum, 1E-6); assertArrayEquals(new double[] {255, 255, 255, 255}, maximum, 1E-6); disposeCoverage(output); ImageUtilities.disposePlanarImageChain(extrema); }
/** * Test transparency is preserved when applying an RGB ChannelSelect and ContrastEnhancement * style to an imageMosaic with transparent color being set */ @Test public void testTransparentColorWithContrastEnhancementInChannelSelect() throws IOException, NoSuchAuthorityCodeException, FactoryException { File mosaicDirectory = prepareDirectory("transparentCECS"); GridCoverage2D gc = readCoverage(mosaicDirectory, FootprintBehavior.None, Color.BLACK); RenderedImage ri = gc.getRenderedImage(); RenderedOp extrema = ExtremaDescriptor.create(ri, null, 1, 1, false, 1, null); double[] minimum = (double[]) extrema.getProperty("minimum"); double[] maximum = (double[]) extrema.getProperty("maximum"); // read values, not stretched, alpha is present assertArrayEquals(new double[] {0, 0, 0, 0}, minimum, 1E-6); assertArrayEquals(new double[] {54, 54, 54, 255}, maximum, 1E-6); GridCoverage2D output = (GridCoverage2D) symbolizeRaster(gc, "ce_cs.sld"); ri = output.getRenderedImage(); // Assert the alpha band has been preserved, even with a CS+CE SLD in place assertHasAlpha(ri); extrema = ExtremaDescriptor.create(ri, null, 1, 1, false, 1, null); minimum = (double[]) extrema.getProperty("minimum"); maximum = (double[]) extrema.getProperty("maximum"); // values are stretched assertArrayEquals(new double[] {0, 0, 0, 0}, minimum, 1E-6); assertArrayEquals(new double[] {255, 255, 255, 255}, maximum, 1E-6); disposeCoverage(output); ImageUtilities.disposePlanarImageChain(extrema); }
final Object o = image.getProperty(ImageReadDescriptor.PROPERTY_NAME_IMAGE_READER); if (o instanceof ImageReader) { final ImageReader reader = (ImageReader) o;
RenderedOp op = (RenderedOp) image; Object mtProperty = op.getProperty("MathTransform"); Object sourceBoundsProperty = op.getProperty("SourceBoundingBox"); String opName = op.getOperationName(); image = result; Object prop = result.getProperty("roi"); if (prop != null && prop instanceof ROI) { setROI((ROI) prop);
@SuppressWarnings("unchecked") final Collection<LineString> prop = (Collection<LineString>) dest.getProperty(ContourDescriptor.CONTOUR_PROPERTY_NAME);
RenderedOp extremaOp = ExtremaDescriptor.create(ri, null, 1, 1, false, 1, renderingHints); double[][] extrema = (double[][]) extremaOp.getProperty("Extrema"); double[] mins = extrema[0];
@SuppressWarnings("unchecked") final Collection<Polygon> prop = (Collection<Polygon>) dest.getProperty(VectorizeDescriptor.VECTOR_PROPERTY_NAME);
public void setImage(PlanarImage wrapRenderedImage) { try { setHistogram((Histogram) HistogramDescriptor.create( wrapRenderedImage, null, 1, 1, new int[] { 65536 }, new double[] { 0 }, new double[] { 65535 }, null).getProperty("histogram")); } catch(Exception e) { e.printStackTrace(); setHistogram(null); } }
private static int getCompression(RenderedOp op) throws Exception { int TAG_COMPRESSION = 259; TIFFDirectory dir = (TIFFDirectory)op.getProperty("tiff_directory"); if(dir.isTagPresent(TAG_COMPRESSION)) { TIFFField compField = dir.getField(TAG_COMPRESSION); return compField.getAsInt(0); } return 0; }
public void setImage(PlanarImage wrapRenderedImage) { try { setHistogram((Histogram) HistogramDescriptor.create( wrapRenderedImage, null, 1, 1, new int[] { 65536 }, new double[] { 0 }, new double[] { 65535 }, null).getProperty("histogram")); } catch(Exception e) { e.printStackTrace(); setHistogram(null); } }
public static double[][] getExtrema(RenderedImage src) { ParameterBlock pb = new ParameterBlock(); pb.addSource(src); RenderedOp op = JAI.create("extrema", pb, null); return (double[][]) op.getProperty("extrema"); }
private Double[][] getExtrema(RenderedImage image) { RenderedOp extremaOp = ExtremaDescriptor.create(image, null, 1, 1, false, 1, null); double[][] extrema= (double[][]) extremaOp.getProperty("extrema"); Double[][] result = new Double[2][]; result[0] = new Double[] {extrema[0][0]}; result[1] = new Double[] {extrema[1][0]}; return result; } }
public static BufferedImage convertToBinary(BufferedImage sourceImg){ double[][] matrix = {{ 0.3D, 0.59D, 0.11D, 0D }}; ParameterBlock pb = new ParameterBlock(); pb.addSource(sourceImg); pb.add(matrix); PlanarImage src = JAI.create("BandCombine", pb, null); // Generate a histogram. Histogram histogram = (Histogram)JAI.create("histogram", src).getProperty("histogram"); // Get a threshold equal to the median. double[] threshold = histogram.getPTileThreshold(0.5); // Binarize the image. PlanarImage dst = JAI.create("binarize", src, new Double(threshold[0])); return dst.getAsBufferedImage(); }
public static double getMax(final RenderedImage image) { final ParameterBlock pb = new ParameterBlock(); pb.addSource(image); pb.add(null); // null ROI means whole image pb.add(1); // check every pixel horizontally pb.add(1); // check every pixel vertically // Perform the extrema operation on the source image final RenderedOp op = JAI.create("extrema", pb); // Retrieve both the maximum and minimum pixel value final double[][] extrema = (double[][]) op.getProperty("extrema"); return extrema[1][0]; }
public static double getBinarizationThreshold(RenderedImage image) { ParameterBlock pb = getParameterBlockForImage(image); pb.add(null); // The ROI pb.add(1); pb.add(1); pb.add(new int[] { 256 }); pb.add(new double[] { 0 }); pb.add(new double[] { 256 }); Histogram histogram = (Histogram) JAI.create("histogram", pb).getProperty("histogram"); return histogram.getMinFuzzinessThreshold()[0]; }
private void assertImageEquals(RenderedOp first, RenderedOp second) { // Calculation of the image difference RenderedOp difference = SubtractDescriptor.create(first, second, null); // Selection of the Statistics StatsType[] statsType = new StatsType[] { StatsType.EXTREMA }; // Calculation of the statistics RenderedOp stats = StatisticsDescriptor.create(difference, 1, 1, null, null, false, new int[] { 0, 1, 2 }, statsType, null); Statistics[][] results = (Statistics[][]) stats.getProperty(Statistics.STATS_PROPERTY); // Check if the Maximum and minimum for each band are equals for (int i = 0; i < results.length; i++) { double[] data = (double[]) results[i][0].getResult(); assertEquals(data[0], data[1], 0.0); } }