當前位置: 首頁>>代碼示例>>Java>>正文


Java JAI.KEY_IMAGE_LAYOUT屬性代碼示例

本文整理匯總了Java中javax.media.jai.JAI.KEY_IMAGE_LAYOUT屬性的典型用法代碼示例。如果您正苦於以下問題:Java JAI.KEY_IMAGE_LAYOUT屬性的具體用法?Java JAI.KEY_IMAGE_LAYOUT怎麽用?Java JAI.KEY_IMAGE_LAYOUT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在javax.media.jai.JAI的用法示例。


在下文中一共展示了JAI.KEY_IMAGE_LAYOUT屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: makeTiledImage

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;
}
 
開發者ID:mstritt,項目名稱:orbit-image-analysis,代碼行數:13,代碼來源:ImageTiler.java

示例2: createProjectedImage

private MultiLevelImage createProjectedImage(final GeoCoding sourceGeoCoding, final MultiLevelImage sourceImage,
                                             MultiLevelModel sourceModel, final Band targetBand, final Interpolation resampling,
                                             MultiLevelModel targetModel, Reproject reprojection) {
    final CoordinateReferenceSystem sourceModelCrs = Product.findModelCRS(sourceGeoCoding);
    final CoordinateReferenceSystem targetModelCrs = Product.findModelCRS(targetBand.getGeoCoding());
    final AffineTransform sourceImageToMapTransform = Product.findImageToModelTransform(sourceGeoCoding);
    final AffineTransform targetImageToMapTransform = Product.findImageToModelTransform(targetBand.getGeoCoding());

    return new DefaultMultiLevelImage(new AbstractMultiLevelSource(targetModel) {

        @Override
        public RenderedImage createImage(int targetLevel) {
            final double targetScale = targetModel.getScale(targetLevel);
            final int sourceLevel = sourceImage.getModel().getLevel(targetScale);
            RenderedImage leveledSourceImage = sourceImage.getImage(sourceLevel);

            final Rectangle sourceBounds = new Rectangle(leveledSourceImage.getMinX(),
                    leveledSourceImage.getMinY(),
                    leveledSourceImage.getWidth(),
                    leveledSourceImage.getHeight());

            // the following transformation maps the source level image to level zero and then to the model,
            // which either is a map or an image CRS
            final AffineTransform i2mSource = sourceModel.getImageToModelTransform(sourceLevel);
            i2mSource.concatenate(sourceModel.getModelToImageTransform(0));
            i2mSource.concatenate(sourceImageToMapTransform);
            ImageGeometry sourceGeometry = new ImageGeometry(sourceBounds,
                    sourceModelCrs,
                    i2mSource);

            ImageLayout imageLayout = ImageManager.createSingleBandedImageLayout(
                    ImageManager.getDataBufferType(targetBand.getDataType()),
                    targetBand.getRasterWidth(),
                    targetBand.getRasterHeight(),
                    targetProduct.getPreferredTileSize(),
                    ResolutionLevel.create(getModel(), targetLevel));
            Rectangle targetBounds = new Rectangle(imageLayout.getMinX(null), imageLayout.getMinY(null),
                    imageLayout.getWidth(null), imageLayout.getHeight(null));

            // the following transformation maps the target level image to level zero and then to the model,
            // which always is a map
            final AffineTransform i2mTarget = getModel().getImageToModelTransform(targetLevel);
            i2mTarget.concatenate(getModel().getModelToImageTransform(0));
            i2mTarget.concatenate(targetImageToMapTransform);

            ImageGeometry targetGeometry = new ImageGeometry(targetBounds,
                    targetModelCrs,
                    i2mTarget);
            Hints hints = new Hints(JAI.KEY_IMAGE_LAYOUT, imageLayout);
            hints.put(Hints.LENIENT_DATUM_SHIFT, Boolean.TRUE);

            Dimension tileSize = ImageManager.getPreferredTileSize(targetProduct);
            try {
                return reprojection.reproject(leveledSourceImage, sourceGeometry, targetGeometry,
                        targetBand.getNoDataValue(), resampling, hints, targetLevel,
                        tileSize);
            } catch (FactoryException | TransformException e) {
                Debug.trace(e);
                throw new RuntimeException(e);
            }
        }
    });
}
 
開發者ID:senbox-org,項目名稱:s2tbx,代碼行數:63,代碼來源:S2tbxReprojectionOp.java

示例3: getROIData

private byte[] getROIData(ROI roi, Rectangle rectIMG) {
    byte[] dataROI;
    PlanarImage roiIMG = roi.getAsImage();
    Rectangle rectROI = roiIMG.getBounds();
    // Forcing to component colormodel in order to avoid packed bits
    ImageWorker w = new ImageWorker();
    w.setImage(roiIMG);
    w.forceComponentColorModel();
    RenderedImage img = w.getRenderedImage();
    //
    BufferedImage test = new BufferedImage(rectIMG.width, rectIMG.height,
            BufferedImage.TYPE_BYTE_GRAY);
    ImageLayout2 layout = new ImageLayout2(test);
    layout.setMinX(img.getMinX());
    layout.setMinY(img.getMinY());
    layout.setWidth(img.getWidth());
    layout.setHeight(img.getHeight());
    // Lookup
    byte[] lut = new byte[256];
    lut[255] = 1;
    lut[1] = 1;
    LookupTableJAI table = new LookupTableJAI(lut);
    RenderingHints hints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout);
    RenderedOp transformed = LookupDescriptor.create(img, table, hints);

    Graphics2D gc2d = null;
    // Translation parameters in order to position the ROI data correctly in the Raster Space
    int trX = -rectIMG.x + rectROI.x - rectIMG.x;
    int trY = -rectIMG.y + rectROI.y - rectIMG.y;
    try {
        gc2d = test.createGraphics();
        gc2d.drawRenderedImage(transformed,
                AffineTransform.getTranslateInstance(trX, trY));
    } finally {
        gc2d.dispose();
    }
    Rectangle testRect = new Rectangle(rectIMG.width, rectIMG.height);
    DataBufferByte dbRoi = (DataBufferByte) test.getData(testRect).getDataBuffer();
    dataROI = dbRoi.getData();
    // BufferedImage is stored in memory so the planarImage chain before can be disposed
    ImageUtilities.disposePlanarImageChain(transformed);
    // Flush of the BufferedImage
    test.flush();

    return dataROI;
}
 
開發者ID:geosolutions-it,項目名稱:soil_sealing,代碼行數:46,代碼來源:ChangeMatrixProcess.java

示例4: getRenderingHints

/**
 * Defines RenderingHints for JAI create operations (otherwise JAI will use defaultTileSize tiling)
 *
 * @param image
 * @return
 */
public static RenderingHints getRenderingHints(PlanarImage image) {
    ImageLayout layout = new ImageLayout(image.getMinX(), image.getMinY(), image.getWidth(), image.getHeight(), image.getTileGridXOffset(), image.getTileGridYOffset(), image.getTileWidth(), image.getTileHeight(), image.getSampleModel(), image.getColorModel());
    RenderingHints renderingHints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout);
    return renderingHints;
}
 
開發者ID:mstritt,項目名稱:orbit-image-analysis,代碼行數:11,代碼來源:ManipulationUtils.java


注:本文中的javax.media.jai.JAI.KEY_IMAGE_LAYOUT屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。