我正在尝试使用 JAI 创建一个由 4 个 TIF 图像组成的马赛克,每个图像的尺寸为 5000 x 5000。我编写的代码如下..
RenderedOp mosaic=null;
ParameterBlock pbMosaic=new ParameterBlock();
pbMosaic.add(MosaicDescriptor.MOSAIC_TYPE_OVERLAY);
RenderedOp in=null;
// Get 4 tiles and add them to the Mosaic
in=returnRenderedOp(path,"northwest.tif");
pbMosaic.addSource(in);
in=returnRenderedOp(path,"northeast.tif");
pbMosaic.addSource(in);
in=returnRenderedOp(path,"southwest.tif");
pbMosaic.addSource(in);
in=returnRenderedOp(path,"southeast.tif");
pbMosaic.addSource(in);
// Setup the ImageLayout
ImageLayout imageLayout=new ImageLayout(0,0,10000,10000);
imageLayout.setTileWidth(5000);
imageLayout.setTileHeight(5000);
imageLayout.setColorModel(in.getColorModel());
imageLayout.setSampleModel(in.getSampleModel());
mosaic=JAI.create("mosaic",pbMosaic,new RenderingHints(JAI.KEY_IMAGE_LAYOUT,imageLayout));
问题是所有 4 个图像都位于马赛克左上角的同一位置,因此其他四分之三是空的。谁能告诉我如何选择构成马赛克的每张图片的位置,以便每张图片都出现在正确的位置?
谢谢
伊恩
最佳答案
我认为您误解了您需要在操作之前为每个源图像设置 minX minY 的文档。
northwest.tif 应具有 minX=0 和 minY=0,
northeast.tif 应具有 minX=5000 和 minY=0,
southwest.tif 应具有 minX=0、minY=5000 和
southeast.tif 应该有 minx=5000 和 minY = 5000
在文档中,他们建议您通过在反序列化操作上使用渲染提示来直接“移动”文件来反序列化。
不知何故,马赛克只是一个普通的合成操作。
关于java - 使用 JAI 创建图像马赛克时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2768128/