Java Code Examples for javax.media.jai.ImageLayout#setTileWidth()
The following examples show how to use
javax.media.jai.ImageLayout#setTileWidth() .
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: ImageTiler.java From orbit-image-analysis with GNU General Public License v3.0 | 5 votes |
private PlanarImage makeTiledImage(PlanarImage img, int tileWidth, int tileHeight) { ImageLayout tileLayout = new ImageLayout(img); tileLayout.setTileWidth(tileWidth); tileLayout.setTileHeight(tileHeight); tileLayout.setSampleModel(img.getColorModel().createCompatibleSampleModel(tileWidth,tileHeight)); tileLayout.setColorModel(img.getColorModel()); RenderingHints tileHints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, tileLayout); ParameterBlock pb = new ParameterBlock(); pb.addSource(img); PlanarImage pi = JAI.create("format", pb, tileHints); pi.getWidth(); return pi; }
Example 2
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)); }