final int ssWidth = image.getWidth(); final int ssHeight = image.getHeight();
this.xmax = x + image.getWidth(); this.ymax = y + image.getHeight();
/******************************************************************************* * * @inheritDoc * ******************************************************************************/ public int getWidth() { return getPlanarImage().getWidth(); }
/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ @Nonnegative @Override public int getWidth() { return getPlanarImage().getWidth(); }
DefaultPixelFinder(PlanarImage lonImage, PlanarImage latImage, PlanarImage maskImage, double pixelDiagonalSquared) { this.lonImage = lonImage; this.latImage = latImage; this.maskImage = maskImage; this.pixelDiagonalSquared = pixelDiagonalSquared; imageW = lonImage.getWidth(); imageH = lonImage.getHeight(); }
PodPixelFinder(PlanarImage lonImage, PlanarImage latImage, PlanarImage maskImage, double angularTolerance) { this.lonImage = lonImage; this.latImage = latImage; this.maskImage = maskImage; this.tolerance = 1.0 - Math.cos(Math.toRadians(angularTolerance)); imageW = lonImage.getWidth(); imageH = lonImage.getHeight(); }
import java.net.MalformedURLException; import java.net.URL; import javax.media.jai.JAI; import javax.media.jai.PlanarImage; class CheckResolution { String imageURL = "test.png"; public static void main(String[] args) throws MalformedURLException { CheckResolution cr = new CheckResolution(); URL imageurl = new URL(cr.imageURL); PlanarImage pi = JAI.create("url", imageurl); int imagewidth = pi.getWidth(); int imageheight = pi.getHeight(); System.out.println("Image Width:" + imagewidth + " --- Image Height:" + imageheight); } }
private List<Rectangle> computeRectangles(List<PlanarImage> images) { List<Rectangle> reg = new ArrayList<>(); Set<Integer> xSet= new TreeSet<>(); Set<Integer> ySet = new TreeSet<>(); for(PlanarImage image: images){ xSet.add(image.getMinX()); xSet.add(image.getMinX() + image.getWidth()); ySet.add(image.getMinY()); ySet.add(image.getMinY() + image.getHeight()); } Integer[] xArray = xSet.toArray(new Integer[xSet.size()]); Integer[] yArray = ySet.toArray(new Integer[ySet.size()]); for(int x = 0; x < xArray.length - 1; x++){ for(int y = 0; y < yArray.length - 1; y++ ){ reg.add(new Rectangle(xArray[x],yArray[y], xArray[x+1]-xArray[x], yArray[y+1]-yArray[y])); } } return reg; }
private static void outputComplexImage(final PlanarImage image) { final int w = image.getWidth(); final int h = image.getHeight(); final Raster dftData = image.getData(); final double[] real = dftData.getSamples(0, 0, w, h, 0, (double[]) null); final double[] imag = dftData.getSamples(0, 0, w, h, 1, (double[]) null); System.out.println("Real part:"); for (double v : real) { System.out.print(v + ", "); } System.out.println(); System.out.println("Imaginary part:"); for (double v : imag) { System.out.print(v + ", "); } System.out.println(); }
@Override @Nonnull protected PlanarImage execute (final @Nonnull CenterShiftOp operation, final @Nonnull EditableImage image, final @Nonnull PlanarImage planarImage) { final ParameterBlock pb = new ParameterBlock(); pb.addSource(planarImage); pb.addSource(planarImage.getWidth() / 2); pb.addSource(planarImage.getHeight() / 2); final PlanarImage result = JAI.create("periodicshift", pb); JAIUtils.logImage(log, ">>>> CenterShiftJAIOp returning", result); return result; } }
static void ensureImageCompatibility(PlanarImage dataImage, PlanarImage maskImage) { if (maskImage.getSampleModel().getNumBands() != 1) { throw new IllegalStateException("maskSampleModel.numBands != 1"); } if (maskImage.getSampleModel().getDataType() != DataBuffer.TYPE_BYTE) { throw new IllegalStateException("maskSampleModel.dataType != TYPE_BYTE"); } if (maskImage.getMinX() != dataImage.getMinX()) { throw new IllegalStateException("maskImage.getMinX() != dataImage.getMinX()"); } if (maskImage.getMinY() != dataImage.getMinY()) { throw new IllegalStateException("maskImage.getMinY() != dataImage.getMinY()"); } if (maskImage.getWidth() != dataImage.getWidth()) { throw new IllegalStateException("maskImage.getWidth() != dataImage.getWidth()"); } if (maskImage.getHeight() != dataImage.getHeight()) { throw new IllegalStateException("maskImage.getHeight() != dataImage.getHeight()"); } }
public static void describe(GridCoverage2D gc) { System.out.println("Name = " + gc.getName()); GridGeometry2D gridGeometry2D = gc.getGridGeometry(); AffineTransform gridToWorld = (AffineTransform) gridGeometry2D.getGridToCRS2D(); double cellSizeX = Math.abs(gridToWorld.getScaleX()); double cellSizeY = Math.abs(gridToWorld.getScaleY()); System.out.println("CellSizeX = " + cellSizeX); System.out.println("CellSizeY = " + cellSizeY); PlanarImage image = (PlanarImage) gc.getRenderedImage(); System.out.println("Columns = " + image.getWidth()); System.out.println("Rows = " + image.getHeight()); System.out.println("NumberOfBands = " + gc.getNumSampleDimensions()); System.out.println("Bounds = " + image.getBounds()); System.out.println("PixelType = " + RasterHelper.getTransferType(gc)); System.out.println("NoData = " + RasterHelper.getNoDataValue(gc)); System.out.println("Extent = " + gc.getEnvelope()); CoordinateReferenceSystem crs = gc.getCoordinateReferenceSystem(); if (crs != null) { System.out.println(crs.toWKT()); } else { System.out.println("CoordinateReferenceSystem is null!"); } }
String filename = "jEEDL.png"; PlanarImage image = PlanarImage.wrapRenderedImage(JAI.create("fileload", filename)); LookupTableJAI lut = new LookupTableJAI(new byte[][] {{(byte)0x00, (byte)0xff}, {(byte)0x00, (byte)0xff}, {(byte)0x00, (byte)0xff}}); ImageLayout layout = new ImageLayout(); byte[] map = new byte[] {(byte)0x00, (byte)0xff}; ColorModel cm = new IndexColorModel(1, 2, map, map, map); layout.setColorModel(cm); SampleModel sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE, image.getWidth(), image.getHeight(), 1); layout.setSampleModel(sm); RenderingHints hints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, layout); PlanarImage op = ErrorDiffusionDescriptor.create(image, lut, KernelJAI.ERROR_FILTER_FLOYD_STEINBERG, hints); BufferedImage dst = op.getAsBufferedImage(); JAI.create("filestore", dst, "jEEDL.bmp", "BMP");
.getName() .getCode(), /* {2} */ sourceImage.getWidth(),
private RoiAccessor buildRoiAccessor(ROI sourceROI) { if (sourceROI != null) { final PlanarImage roiImage = sourceROI.getAsImage(); final RandomIter roiIter = RandomIterFactory.create(roiImage, null); final int minRoiX = roiImage.getMinX(); final int minRoiY = roiImage.getMinY(); final int roiW = roiImage.getWidth(); final int roiH = roiImage.getHeight(); return new RoiAccessor(roiIter, sourceROI, roiImage, minRoiX, minRoiY, roiW, roiH); } return null; }
/******************************************************************************* * * @inheritDoc * ******************************************************************************/ protected PlanarImage execute (CenterShiftOp operation, final EditableImage image, PlanarImage planarImage) { ParameterBlock pb = new ParameterBlock(); pb.addSource(planarImage); pb.addSource(planarImage.getWidth() / 2); pb.addSource(planarImage.getHeight() / 2); planarImage = JAI.create("periodicshift", pb); JAIUtils.logImage(logger, ">>>> CenterShiftJAIOp returning", planarImage); return planarImage; } }
static void accumulateTile(StxOp op, PlanarImage dataImage, PlanarImage maskImage, PixelAccessor dataAccessor, PixelAccessor maskAccessor, int tileX, int tileY) { final Raster dataTile = dataImage.getTile(tileX, tileY); if (!(dataTile instanceof NoDataRaster)) { // data and mask image might not have the same tile size // --> we can not use the tile index of the one for the other, so we use the bounds final Raster maskTile = maskImage != null ? maskImage.getData(dataTile.getBounds()) : null; final Rectangle rect = new Rectangle(dataImage.getMinX(), dataImage.getMinY(), dataImage.getWidth(), dataImage.getHeight()) .intersection(dataTile.getBounds()); final UnpackedImageData dataPixels = dataAccessor.getPixels(dataTile, rect, dataImage.getSampleModel().getDataType(), false); final UnpackedImageData maskPixels = maskAccessor != null ? maskAccessor.getPixels(maskTile, rect, DataBuffer.TYPE_BYTE, false) : null; op.accumulateData(dataPixels, maskPixels); } }
layout.setMinX(alphaArray[i].getMinX()); layout.setMinY(alphaArray[i].getMinY()); layout.setWidth(alphaArray[i].getWidth()); layout.setHeight(alphaArray[i].getHeight()); w1.setRenderingHint(JAI.KEY_IMAGE_LAYOUT, layout);
private void testIntMapOp(int sourceType, int[] sourceSamples, int expectedTargetType, int[] expectedTargetSamples) { final BufferedImage sourceImage = createSourceImage(sourceType, sourceSamples); final IntMap intMap = createIntMap(sourceImage); final PlanarImage targetImage = JAIUtils.createIndexedImage(sourceImage, intMap, 0); Assert.assertNotNull(targetImage); assertEquals(1, targetImage.getNumBands()); assertEquals(sourceImage.getWidth(), targetImage.getWidth()); assertEquals(sourceImage.getHeight(), targetImage.getHeight()); assertEquals(expectedTargetType, targetImage.getSampleModel().getDataType()); final Raster targetData = targetImage.getData(); final DataBuffer dataBuffer = targetData.getDataBuffer(); for (int i = 0; i < expectedTargetSamples.length; i++) { final int elem = dataBuffer.getElem(i); assertEquals("i=" + i, expectedTargetSamples[i], elem); } }