/** * Constructs a parameter group for the specified descriptor. * * @param descriptor The descriptor for this group of parameters. */ public ImagingParameters(final ImagingParameterDescriptors descriptor) { super(descriptor); if (descriptor.operation instanceof OperationDescriptor) { // Parameters with sources parameters = new ParameterBlockJAI( (OperationDescriptor) descriptor.operation, descriptor.registryMode); } else { // Parameters without sources parameters = new ParameterListImpl(descriptor.descriptor); } }
public static RenderedOp create(RenderedImage source0, FillType type, RenderingHints hints) { ParameterBlockJAI pb = new ParameterBlockJAI("TransparencyFill", RenderedRegistryMode.MODE_NAME); pb.setSource("source0", source0); pb.setParameter("type", type); return JAI.create("TransparencyFill", pb, hints); } }
/** * Loads an image using the provided file name and the {@linkplain #getRenderingHints current * hints}, which are used to control caching and layout. * * @param source Filename of the source image to read. * @param imageChoice Image index in multipage images. * @param readMatadata If {@code true}, metadata will be read. */ public final void load(final String source, final int imageChoice, final boolean readMetadata) { final ParameterBlockJAI pbj = new ParameterBlockJAI("ImageRead"); pbj.setParameter("Input", source) .setParameter("ImageChoice", Integer.valueOf(imageChoice)) .setParameter("ReadMetadata", Boolean.valueOf(readMetadata)) .setParameter("VerifyInput", Boolean.TRUE); image = JAI.create("ImageRead", pbj, getRenderingHints()); }
@Before public void setUp() throws Exception { try { new ParameterBlockJAI(GenericPiecewiseOpImage.OPERATION_NAME); } catch (Exception e) { // GenericPiecewiseOpImage.register(JAI.getDefaultInstance()); } // check that it exisits File file = TestData.copy(this, "arcgrid/arcgrid.zip"); Assert.assertTrue(file.exists()); // unzip it TestData.unzipFile(this, "arcgrid/arcgrid.zip"); } }
/** * Forcefully registers the specified rendered operation in the JAI registry * * @param descriptor * @param rif * @param productName * @return true if the registration succeded, false if the registration was not required as the * operation was already available in the registry */ public static boolean registerRIF( final JAI jai, OperationDescriptor descriptor, RenderedImageFactory rif, String productName) { final OperationRegistry registry = jai.getOperationRegistry(); try { // see if the operation is already registered, avoid registering it twice new ParameterBlockJAI(descriptor.getName()); return false; } catch (Exception e) { registry.registerDescriptor(descriptor); final String descName = descriptor.getName(); registry.registerFactory(RenderedRegistryMode.MODE_NAME, descName, productName, rif); return true; } }
/** * Stop gap measure to get a ROI that can scale up to massive images, until ROIGeometry gets * fixed to be a good ROIShape replacement * * @param theGeom * @return */ private static ROI getAsROI(Geometry theGeom) { org.locationtech.jts.geom.Envelope env = theGeom.getEnvelopeInternal(); int x = (int) Math.floor(env.getMinX()); int y = (int) Math.floor(env.getMinY()); int w = (int) Math.ceil(env.getMaxX()) - x; int h = (int) Math.ceil(env.getMaxY()) - y; ParameterBlockJAI pb = new ParameterBlockJAI("VectorBinarize"); pb.setParameter("minx", x); pb.setParameter("miny", y); pb.setParameter("width", w); pb.setParameter("height", h); pb.setParameter("geometry", PreparedGeometryFactory.prepare(theGeom)); pb.setParameter("antiAliasing", true); RenderedImage roiImage = JAI.create("VectorBinarize", pb, null); return new ROI(roiImage); } }
public static ParameterBlockJAI getParameterBlockJAIForImage(RenderedImage image, String op) { ParameterBlockJAI pb = new ParameterBlockJAI(op); pb.addSource(image); return pb; }
ParameterBlockJAI pbj = new ParameterBlockJAI("ZonalStats"); pbj.addSource(sourceImage); pbj.setParameter("stats", stats.toArray(new Statistic[stats.size()]));
ParameterBlockJAI pb = new ParameterBlockJAI("Contour"); pb.setSource("source0", raster);
ParameterBlockJAI pb = new ParameterBlockJAI("Vectorize"); pb.setSource("source0", raster);
private RenderedImage mosaicHeterogeneousImages(List<ImageInTile> sources) { // at the time of writing, only JAI-EXT mosaic can handle a mix of different // color models, we need to use it explicitly RenderedImage image; final ParameterBlockJAI pb = new ParameterBlockJAI(new it.geosolutions.jaiext.mosaic.MosaicDescriptor()); for (ImageInTile it : sources) { if (it.posx != 0 || it.posy != 0) { ImageWorker iw = new ImageWorker(it.image); iw.translate( it.posx, it.posy, Interpolation.getInstance(Interpolation.INTERP_NEAREST)); RenderedImage translated = iw.getRenderedImage(); pb.addSource(translated); } else { pb.addSource(it.image); } } pb.setParameter("mosaicType", MosaicDescriptor.MOSAIC_TYPE_OVERLAY); pb.setParameter("sourceAlpha", null); pb.setParameter("sourceROI", null); pb.setParameter("sourceThreshold", null); pb.setParameter("backgroundValues", new double[] {0}); pb.setParameter("nodata", null); RenderingHints hints = new Hints(JAI.getDefaultInstance().getRenderingHints()); hints.putAll(GeoTools.getDefaultHints()); image = new MosaicRIF().create(pb, hints); return image; }
final ParameterBlockJAI pbjImageWrite = new ParameterBlockJAI("ImageWrite"); pbjImageWrite.addSource(image); pbjImageWrite.setParameter("Output", outstream);
protected PlanarImage scaleUnit(PlanarImage image) { final RenderingHints hints = new RenderingHints(JAI.KEY_BORDER_EXTENDER, BorderExtender.createInstance(BorderExtender.BORDER_ZERO)); final ParameterBlockJAI pb = new ParameterBlockJAI("DivideByConst", RenderedRegistryMode.MODE_NAME); pb.setSource("source0", image); pb.setParameter("constants", new double[] { scaleArea }); return JAI.create("DivideByConst", pb, hints); }
@BeforeClass public static void setUp() throws Exception { try { new ParameterBlockJAI(GenericPiecewiseOpImage.OPERATION_NAME); } catch (Exception e) { Assert.assertTrue("GenericPiecewise not registered", false); } // check that it exisits File file = TestData.file(TestPiecewise.class, "test.tif"); Assert.assertTrue(file.exists()); }
public RenderedOp create(RenderedImage source0, ColorMapTransform domain1D, Integer bandIndex, ROI roi, Range nodata, RenderingHints hints) { ParameterBlockJAI pb = new ParameterBlockJAI(RasterClassifierOpImage.OPERATION_NAME, RenderedRegistryMode.MODE_NAME); // Setting source pb.setSource(source0, 0); // Setting parameters pb.setParameter("Domain1D", domain1D); pb.setParameter("bandIndex", bandIndex); pb.setParameter("roi", roi); pb.setParameter("nodata", nodata); return JAI.create(RasterClassifierOpImage.OPERATION_NAME, pb, hints); } }
/** * Applies the operation and tests the result with the expected one, using checksum. */ @Test public void testOnRGB() { loadSampleImage(SampleImage.RGB_ROTATED); final ParameterBlockJAI parameters = new ParameterBlockJAI(SilhouetteMask.OPERATION_NAME); applyUnary(parameters, 2197236510L); showCurrentImage("testOnRGB"); }
@Test public void createSequentialImage() throws Exception { ParameterBlockJAI pb = new ParameterBlockJAI("Jiffle"); String script = "dest = y() * width() + x();" ; pb.setParameter("script", script); pb.setParameter("destName", "dest"); Rectangle bounds = new Rectangle(0, 0, WIDTH, WIDTH); pb.setParameter("destBounds", bounds); RenderedOp op = JAI.create("Jiffle", pb); RenderedImage result = op.getRendering(); assertResult(result, script); }
/** * Applies the operation and tests the result with the expected one, using checksum. */ @Test public void testOnIndexed() { loadSampleImage(SampleImage.INDEXED); final ParameterBlockJAI parameters = new ParameterBlockJAI(SilhouetteMask.OPERATION_NAME); parameters.setParameter("background", new double[][] {{255}}); applyUnary(parameters, 3206331653L); showCurrentImage("testOnIndexed"); } }
private RenderedOp doOp(RenderedImage srcImg, RangeLookupTable table, ROI roi, Double defaultValue) { ParameterBlockJAI pb = new ParameterBlockJAI("RLookup"); pb.setSource("source0", srcImg); pb.setParameter("table", table); pb.setParameter("roi", roi); pb.setParameter("default", defaultValue); return JAI.create("RLookup", pb); }
@Test public void getMissingProperty() { RenderedImage image = createImage(); ParameterBlockJAI pb = new ParameterBlockJAI(new ClassBreaksDescriptor()); pb.addSource(image); pb.setParameter("method", ClassificationMethod.QUANTILE); pb.setParameter("numClasses", 5); // raw creation like in CoverageClassStats, otherwise the issue gets masked by JAI wrappers RenderedImage op = new ClassBreaksRIF().create(pb, null); // used to NPE here Object roi = op.getProperty("ROI"); assertEquals(Image.UndefinedProperty, roi); }