javax.media.jai.ParameterBlockJAI Java Examples
The following examples show how to use
javax.media.jai.ParameterBlockJAI.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OmsVectorizer.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
/** * Helper function to run the Vectorize operation with given parameters and * retrieve the vectors. * * @param src the source image * @param args a {@code Map} of parameter names and values * * @return the generated vectors as JTS Polygons */ @SuppressWarnings("unchecked") private Collection<Polygon> doVectorize( RenderedImage src, Map<String, Object> args ) { ParameterBlockJAI pb = new ParameterBlockJAI("Vectorize"); pb.setSource("source0", src); // Set any parameters that were passed in for( Entry<String, Object> e : args.entrySet() ) { pb.setParameter(e.getKey(), e.getValue()); } // Get the desintation image: this is the unmodified source image data // plus a property for the generated vectors RenderedOp dest = JAI.create("Vectorize", pb); // Get the vectors Object property = dest.getProperty(VectorizeDescriptor.VECTOR_PROPERTY_NAME); return (Collection<Polygon>) property; }
Example #2
Source File: OrbitHelper.java From orbit-image-analysis with GNU General Public License v3.0 | 5 votes |
@Deprecated private static PlanarImage scalePlanarImage(PlanarImage sourceImage, double factor) { ParameterBlockJAI pb = new ParameterBlockJAI("scale", RenderedRegistryMode.MODE_NAME); pb.setSource("source0", sourceImage); pb.setParameter("xScale", new Float(factor)); pb.setParameter("yScale", new Float(factor)); PlanarImage pi = JAI.create("scale", pb); return pi; }
Example #3
Source File: QuicklookSlstrDescriptor.java From DataHubSystem with GNU Affero General Public License v3.0 | 5 votes |
/** * Create the Render Operator to compute SLSTR quicklook. * * <p>Creates a <code>ParameterBlockJAI</code> from all * supplied arguments except <code>hints</code> and invokes * {@link JAI#create(String,ParameterBlock,RenderingHints)}. * * @see JAI * @see ParameterBlockJAI * @see RenderedOp * * @return The <code>RenderedOp</code> destination. * @throws IllegalArgumentException if sources is null. * @throws IllegalArgumentException if a source is null. */ public static RenderedOp create(PixelCorrection[]pixels_correction, RenderingHints hints, RenderedImage... sources) { ParameterBlockJAI pb = new ParameterBlockJAI(OPERATION_NAME, RenderedRegistryMode.MODE_NAME); int numSources = sources.length; // Check on the source number if (numSources <= 0) { throw new IllegalArgumentException("No resources are present"); } // Setting of all the sources for (int index = 0; index < numSources; index++) { RenderedImage source = sources[index]; if (source == null) { throw new IllegalArgumentException("This resource is null"); } pb.setSource(source, index); pb.setParameter(paramNames[0], pixels_correction); } return JAI.create(OPERATION_NAME, pb, hints); }
Example #4
Source File: QuicklookOlciDescriptor.java From DataHubSystem with GNU Affero General Public License v3.0 | 5 votes |
/** * Create the Render Operator to compute Olci quicklook. * * <p>Creates a <code>ParameterBlockJAI</code> from all * supplied arguments except <code>hints</code> and invokes * {@link JAI#create(String,ParameterBlock,RenderingHints)}. * * @see JAI * @see ParameterBlockJAI * @see RenderedOp * * @param source_red the RenderedImage red source. * @param source_green the RenderedImage green source. * @param source_blue the RenderedImage blue source. * @param detectors list of detector indexes. * @param sza list of solar zenith angles. * @param solar_flux list of solar flux. * @param pixels_correction per bands scale/offset pixels correction * @param bands list of bands in the order they are provided. * @param bands_coefficients list of global coefficient per bands. * @return The <code>RenderedOp</code> destination. * @throws IllegalArgumentException if sources is null. * @throws IllegalArgumentException if a source is null. */ public static RenderedOp create(short[][] detectors, double[][]sza, float[][]solar_flux, PixelCorrection[]pixels_correction, int[]bands, int[]bands_coefficients, RenderingHints hints, RenderedImage... sources) { ParameterBlockJAI pb = new ParameterBlockJAI(OPERATION_NAME, RenderedRegistryMode.MODE_NAME); int numSources = sources.length; // Check on the source number if (numSources <= 0) { throw new IllegalArgumentException("No resources are present"); } // Setting of all the sources for (int index = 0; index < numSources; index++) { RenderedImage source = sources[index]; if (source == null) { throw new IllegalArgumentException("This resource is null"); } pb.setSource(source, index); } /*To Be remove */ pb.setParameter(paramNames[0], detectors); pb.setParameter(paramNames[1], sza); pb.setParameter(paramNames[2], solar_flux); pb.setParameter(paramNames[3], pixels_correction); pb.setParameter(paramNames[4], bands); pb.setParameter(paramNames[5], bands_coefficients); return JAI.create(OPERATION_NAME, pb, hints); }
Example #5
Source File: S3HistogramEqualizerDescriptor.java From DataHubSystem with GNU Affero General Public License v3.0 | 5 votes |
/** * Render the Equalization of pixels of the image. * * <p>Creates a <code>ParameterBlockJAI</code> from all * supplied arguments except <code>hints</code> and invokes * {@link JAI#create(String,ParameterBlock,RenderingHints)}. * * @see JAI * @see ParameterBlockJAI * @see RenderedOp * * @param hints processing image hints. * @param sources list of sources. * @return The <code>RenderedOp</code> destination. * @throws IllegalArgumentException if <code>sources</code> is <code>null</code>. * @throws IllegalArgumentException if a <code>source</code> is <code>null</code>. */ public static RenderedOp create(RenderingHints hints, RenderedImage... sources) { ParameterBlockJAI pb = new ParameterBlockJAI(OPERATION_NAME, RenderedRegistryMode.MODE_NAME); int numSources = sources.length; // Check on the source number if (numSources <= 0) { throw new IllegalArgumentException("No resources are present"); } // Setting of all the sources for (int index = 0; index < numSources; index++) { RenderedImage source = sources[index]; if (source == null) { throw new IllegalArgumentException("This resource is null"); } pb.setSource(source, index); } return JAI.create(OPERATION_NAME, pb, hints); }
Example #6
Source File: FeatureUtilities.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
/** * Helper function to run the Vectorize operation with given parameters and * retrieve the vectors. * * @param src the source {@link GridCoverage2D}. * @param args a {@code Map} of parameter names and values or <code>null</code>. * * @return the generated vectors as JTS Polygons */ @SuppressWarnings("unchecked") public static Collection<Polygon> doVectorize( GridCoverage2D src, Map<String, Object> args ) { if (args == null) { args = new HashMap<String, Object>(); } ParameterBlockJAI pb = new ParameterBlockJAI("Vectorize"); pb.setSource("source0", src.getRenderedImage()); // Set any parameters that were passed in for( Entry<String, Object> e : args.entrySet() ) { pb.setParameter(e.getKey(), e.getValue()); } // Get the desintation image: this is the unmodified source image data // plus a property for the generated vectors RenderedOp dest = JAI.create("Vectorize", pb); // Get the vectors Collection<Polygon> polygons = (Collection<Polygon>) dest.getProperty(VectorizeDescriptor.VECTOR_PROPERTY_NAME); RegionMap regionParams = CoverageUtilities.getRegionParamsFromGridCoverage(src); double xRes = regionParams.getXres(); double yRes = regionParams.getYres(); final AffineTransform mt2D = (AffineTransform) src.getGridGeometry().getGridToCRS2D(PixelOrientation.CENTER); final AffineTransformation jtsTransformation = new AffineTransformation(mt2D.getScaleX(), mt2D.getShearX(), mt2D.getTranslateX() - xRes / 2.0, mt2D.getShearY(), mt2D.getScaleY(), mt2D.getTranslateY() + yRes / 2.0); for( Polygon polygon : polygons ) { polygon.apply(jtsTransformation); } return polygons; }
Example #7
Source File: Sentinel2Image.java From DataHubSystem with GNU Affero General Public License v3.0 | 4 votes |
public static RenderedImage process1BImage (DrbCollectionImage source, int bands, int horizontal_padding, int vertical_padding) { // Prepare output mosaic layout ImageLayout layout = new ImageLayout(); boolean isLayoutTileSet = false; // Prepare variables for building output strip mosaic int currentWidth = horizontal_padding; int currentHeight = vertical_padding; ParameterBlockJAI mosaicParameters = new ParameterBlockJAI("Mosaic", "rendered"); mosaicParameters.setParameter("mosaicType", javax.media.jai.operator.MosaicDescriptor.MOSAIC_TYPE_BLEND); Collection<DrbImage>images = source.getChildren(); Iterator<DrbImage> image_it = images.iterator(); while (image_it.hasNext()) { RenderedImage current_image = null; // Select the working bands ParameterBlock pb = new ParameterBlock(); DrbImage fmt = null; if (bands>1) { for (int i=0; i<bands; i++) { fmt = image_it.next(); ParameterBlock fmt_pb = new ParameterBlock(); fmt_pb.addSource(fmt); fmt_pb.add(DataBuffer.TYPE_BYTE); RenderedOp op = JAI.create("Format", fmt_pb); pb.addSource(op); } current_image = JAI.create("bandMerge", pb); } else { //Probably PVI image current_image = image_it.next(); } // Set layout tile size if not already done if (!isLayoutTileSet) { layout.setTileWidth(current_image.getTileWidth()); layout.setTileHeight(current_image.getTileHeight()); layout.setColorModel(current_image.getColorModel()); layout.setSampleModel(current_image.getSampleModel()); isLayoutTileSet = true; } // Translate strip to the output coordinate (vertical shift) ParameterBlock translateParameters = new ParameterBlock(); translateParameters.addSource(current_image); translateParameters.add((float) currentWidth); translateParameters.add((float) currentHeight); translateParameters.add(new InterpolationNearest()); current_image = JAI.create("translate", translateParameters, new RenderingHints(JAI.KEY_IMAGE_LAYOUT,layout)); // TODO: find a way to retrieves the granules position within // the mosaic. // Update following strip translation /* if ((source_index%13)==0) {*/ currentWidth=horizontal_padding; currentHeight += current_image.getHeight() + vertical_padding; /* } else { currentWidth += current_image.getWidth() + horizontal_padding; }*/ // Add current strip to the output mosaic mosaicParameters.addSource(current_image); // Go to the next image } double [] backgroundValues = new double [bands]; for (int j = 0; j < bands; j++) { backgroundValues[j] = 0.0D; } mosaicParameters.setParameter("backgroundValues", backgroundValues); // Create output mosaic return JAI.create("mosaic", mosaicParameters, new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout)); }