public JAIEXTInfoImpl() { if (jaiOperations == null) { jaiOperations = JAI_OPS; } if (jaiExtOperations == null) { jaiExtOperations = JAIEXT_OPS; } if (ImageWorker.isJaiExtEnabled()) { populateOperations(jaiExtOperations); } }
/** * Creates a new uninitialized worker with RenderingHints for a {@linkplain #mosaic mosaic * operation} * * @see #mosaic(RenderedImage[], MosaicType, PlanarImage[], ROI[], double[][], Range[]) */ public ImageWorker(RenderingHints hints) { this(); setRenderingHints(hints); }
/** * The BandMerge operation takes indexed images and expands them, however in the context of * coverage view band merging we don't normally want that, e.g., raster mask bands are * represented as indexed but we really want to keep them in their binary, single band form. To * do so, the IndexColorModel is replaced by a ComponentColorModel * * @param coverage * @return */ private GridCoverage2D prepareForBandMerge(GridCoverage2D coverage) { RenderedImage ri = coverage.getRenderedImage(); SampleModel sampleModel = ri.getSampleModel(); if (sampleModel.getNumBands() == 1 && ri.getColorModel() instanceof IndexColorModel) { ImageWorker worker = new ImageWorker(ri); worker.removeIndexColorModel(); RenderedImage formatted = worker.getRenderedImage(); return new GridCoverageFactory() .create( coverage.getName(), formatted, coverage.getGridGeometry(), coverage.getSampleDimensions(), new GridCoverage[] {coverage}, coverage.getProperties()); } return coverage; }
@Override public RenderedImage process( RenderedImage[] sources, double[] backgroundValues, double[][] inputThreshold, PlanarImage[] sourceAlpha, ROI[] sourceROI, MosaicType mosaicType, RenderingHints localHints) { return new ImageWorker(localHints) .setBackground(backgroundValues) .mosaic(sources, mosaicType, sourceAlpha, sourceROI, inputThreshold, null) .getRenderedImage(); } };
} else { final ImageWorker worker = new ImageWorker(returnValues.get(0).getRenderedImage()); for (int i = 1; i < size; i++) { worker.addBand(returnValues.get(i).getRenderedImage(), false); .create( "result", worker.getRenderedImage(), returnValues.get(0).getEnvelope(), sds,
new ImageWorker(ri).writeTIFF(stream, compression, quality, tileWidth, tileHeight); } else { final GeneralParameterValue[] wps =
/** * Reformats the {@linkplain ColorModel color model} to a {@linkplain ComponentColorModel * component color model} preserving transparency. This is used especially in order to go from * {@link PackedColorModel} to {@link ComponentColorModel}, which seems to be well accepted from * {@code PNGEncoder} and {@code TIFFEncoder}. * * <p>This code is adapted from jai-interests mailing list archive. * * @return this {@link ImageWorker}. * @see FormatDescriptor */ public final ImageWorker forceComponentColorModel() { return forceComponentColorModel(false); }
/** * Retains inconditionnaly the first band of {@linkplain #image}. All other bands (if any) are * discarted without any further processing. * * @return this {@link ImageWorker}. * @see #getNumBands * @see #retainBands * @see BandSelectDescriptor */ public final ImageWorker retainFirstBand() { retainBands(1); // All post conditions for this method contract. assert getNumBands() == 1; return this; }
private void updateNoData(double[] bgValues, RenderedImage image) { if (bgValues != null && bgValues.length > 0) { Range newNoData = extractNoDataProperty(image); if (newNoData != null) { setNoData(newNoData); } } }
/** * Perform a BandMerge operation between the underlying image and the provided one. * * @param image to merge with the underlying one. * @param before <code>true</code> if we want to use first the provided image, <code>false * </code> otherwise. * @return this {@link ImageWorker}. */ public final ImageWorker addBand(RenderedImage image, boolean before) { return addBand(image, before, false, null); }
/** * Reduces the color model to {@linkplain IndexColorModel index color model} with {@linkplain * Transparency#OPAQUE opaque} or {@linkplain Transparency#BITMASK bitmask} transparency. If the * current {@linkplain #image} already uses a suitable color model, then this method do nothing. * * @return this {@link ImageWorker}. * @see #isIndexed * @see #isTranslucent * @see #forceIndexColorModel * @see #forceIndexColorModelForGIF */ public final ImageWorker forceBitmaskIndexColorModel() { forceBitmaskIndexColorModel(getTransparentPixel(), true); return this; }
if (ImageWorker.isJaiExtEnabled()) { if (jai.getJAIEXTInfo() != null) { JAIEXTInfo jaiext = jai.getJAIEXTInfo(); Registry.setNativeAccelerationAllowed("Mosaic", jai.isAllowNativeMosaic(), jaiDef); Registry.setNativeAccelerationAllowed("Warp", jai.isAllowNativeWarp(), jaiDef);
/** * Creates a new builder for the specified image. The images to be computed (if any) will save * their tiles in the default {@linkplain TileCache tile cache}. * * @param image The source image. */ public ImageWorker(final RenderedImage image) { setImage(image); }
/** * Returns the maximal values found in every {@linkplain #image} bands. If a {@linkplain #getROI * region of interest} is defined, then the statistics will be computed only over that region. * * @see #getMinimums * @see #setROI */ public final double[] getMaximums() { return getExtremas()[1]; }
/** * Set the image background value * * @param background The image background. * @return This ImageWorker */ public final ImageWorker setBackground(final double[] background) { this.background = background; invalidateStatistics(); return this; }
/** * Perform a BandMerge operation between the underlying image and the provided one. * * @param image to merge with the underlying one. * @param before <code>true</code> if we want to use first the provided image, <code>false * </code> otherwise. * @param addAlpha <code>true</code> if we want to set the last image as alpha, <code>false * </code> otherwise. * @return this {@link ImageWorker}. */ public final ImageWorker addBands(RenderedImage[] bands, boolean addAlpha, Range[] nodata2) { return addBands(bands, addAlpha, nodata2, null); }
/** * Creates a {@link WritableRectIter} for the specified source and destination iterator. The two * iterators must iterate over a rectangle of the same size, otherwise a {@link * RasterFormatException} may be thrown during the iteration. * * @param src The source iterator. * @param dst The destination iterator. * @return An iterator that read sample from {@code src} and write sample to {@code dst}. If * {@code src == dst}, then the destination iterator itself is returned. */ public static WritableRectIter create(final RectIter src, final WritableRectIter dst) { if (src == dst) { return dst; } return new TransfertRectIter(src, dst); }
/** * Prepare this builder for the specified image. The images to be computed (if any) will save * their tiles in the default {@linkplain TileCache tile cache}. * * @param image The source image. */ public final ImageWorker setImage(final RenderedImage image) { inheritanceStopPoint = this.image = image; setNoData(extractNoDataProperty(image)); return this; }
private static void populateOperations(Set<String> jaiExtOp) { List<OperationItem> jaiextOps = ImageWorker.isJaiExtEnabled() ? JAIExt.getJAIEXTOperations() : JAIExt.getJAIOperations(); for (OperationItem item : jaiextOps) { String name = item.getName(); if (name.equalsIgnoreCase("algebric") || name.equalsIgnoreCase("operationConst") || name.equalsIgnoreCase("Stats") || JAIExt.isJAIAPI(name)) { jaiExtOp.add(name); } } } }
/** * Returns the minimal values found in every {@linkplain #image} bands. If a {@linkplain #getROI * region of interest} is defined, then the statistics will be computed only over that region. * * @see #getMaximums * @see #setROI */ public final double[] getMinimums() { return getExtremas()[0]; }