raster = RasterFactory.createBandedRaster(DataBuffer.TYPE_FLOAT, width, height, 1, null); for (int j = 0; j < height; j++) { int i = 0;
/** * Synthetic with Float Sample Model! * * @return {@linkplain BufferedImage} */ private BufferedImage getSynthetic_Double() { final int width = 500; final int height = 500; final WritableRaster raster = RasterFactory.createBandedRaster(DataBuffer.TYPE_DOUBLE, width, height, 1, null); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { raster.setSample(x, y, 0, (x + y)); } } final ColorModel cm = new ComponentColorModelJAI( ColorSpace.getInstance(ColorSpace.CS_GRAY), false, false, Transparency.OPAQUE, DataBuffer.TYPE_DOUBLE); final BufferedImage image = new BufferedImage(cm, raster, false, null); return image; }
/** * Building a synthetic image upon a FLOAT sample-model. * * @return {@linkplain BufferedImage} */ private BufferedImage getSynthetic_Float() { final int width = 500; final int height = 500; final WritableRaster raster = RasterFactory.createBandedRaster(DataBuffer.TYPE_FLOAT, width, height, 1, null); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { raster.setSample(x, y, 0, (x + y)); } } final ColorModel cm = new ComponentColorModelJAI( ColorSpace.getInstance(ColorSpace.CS_GRAY), false, false, Transparency.OPAQUE, DataBuffer.TYPE_FLOAT); final BufferedImage image = new BufferedImage(cm, raster, false, null); return image; }
/** * Creates a simple 500x500 {@link RenderedImage} for testing purposes. * * <p>Values are randomly set to the provided noDataValue. * * @param noDataValue * @return */ public static RenderedImage getSynthetic(final double noDataValue) { final int width = 500; final int height = 500; final WritableRaster raster = RasterFactory.createBandedRaster(DataBuffer.TYPE_DOUBLE, width, height, 1, null); final Random random = new Random(); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { if (random.nextFloat() > 0.9) raster.setSample(x, y, 0, noDataValue); else raster.setSample(x, y, 0, (x + y)); } } final ColorModel cm = new ComponentColorModelJAI( ColorSpace.getInstance(ColorSpace.CS_GRAY), false, false, Transparency.OPAQUE, DataBuffer.TYPE_DOUBLE); final BufferedImage image = new BufferedImage(cm, raster, false, null); return image; }
if (!castDoubleToFloating) { raster = RasterFactory.createBandedRaster( DataBuffer.TYPE_DOUBLE, rasterMapWidth, rasterMapHeight, 1, null); } else { raster = RasterFactory.createBandedRaster( DataBuffer.TYPE_FLOAT, rasterMapWidth, rasterMapHeight, 1, null); RasterFactory.createBandedRaster( DataBuffer.TYPE_FLOAT, rasterMapWidth, rasterMapHeight, 1, null); } else if (readerMapType > -1) { raster = RasterFactory.createBandedRaster( DataBuffer.TYPE_INT, rasterMapWidth, rasterMapHeight, 1, null); } else {
final int height = 500; final WritableRaster raster = RasterFactory.createBandedRaster(DataBuffer.TYPE_BYTE, width, height, 2, null); final Random random = new Random(); for (int y = 0; y < height; y++) {
public static WritableRaster createRasterTypeDouble(final int numBands, final int tileSize) { final WritableRaster raster = RasterFactory.createBandedRaster( DataBuffer.TYPE_DOUBLE, tileSize, tileSize, numBands, null); final double[] defaultValues = new double[tileSize * tileSize * numBands]; Arrays.fill(defaultValues, Double.NaN); raster.setDataElements(0, 0, tileSize, tileSize, defaultValues); return raster; }
private void checkReset(int type) { if (resetRaster) { raster = RasterFactory.createBandedRaster(type, width, height, 1, null); bimage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); bimage.setAccelerationPriority(1.0f); graphics = bimage.createGraphics(); graphics.setPaintMode(); graphics.setComposite(AlphaComposite.Src); resetRaster = false; } }
/** * Synthetic with Float Sample Model! * * @return {@linkplain BufferedImage} */ private BufferedImage getSyntheticShortImage() { final int width = 500; final int height = 500; final WritableRaster raster = RasterFactory.createBandedRaster(DataBuffer.TYPE_USHORT, width, height, 3, null); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { raster.setSample(x, y, 0, (x + y)); } } final ColorModel cm = new ComponentColorModel( ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), false, false, Transparency.OPAQUE, DataBuffer.TYPE_USHORT); final BufferedImage image = new BufferedImage(cm, raster, false, null); return image; }
/** * Building a synthetic image upon a FLOAT sample-model. * * @return {@linkplain BufferedImage} */ private BufferedImage getSyntheticByteImage() { final int width = 500; final int height = 500; final WritableRaster raster = RasterFactory.createBandedRaster(DataBuffer.TYPE_BYTE, width, height, 3, null); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { raster.setSample(x, y, 0, (x + y)); } } final ColorModel cm = new ComponentColorModel( ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE); final BufferedImage image = new BufferedImage(cm, raster, false, null); return image; }
final int[] zero = new int[1]; raster = RasterFactory.createBandedRaster(buffer, width, height, width, zero, zero, upperLeft); raster = RasterFactory.createBandedRaster(buffer, width, height, width, bankIndices, bandOffsets, upperLeft);
raster = RasterFactory.createBandedRaster(DataBuffer.TYPE_FLOAT, width, height, 1, null); for (int j=0; j<height; j++) { int i = 0;
public LanczosTest() { miny = -1; minx = -2; width = 4; height = 4; double val = -55; rastertest = RasterFactory.createBandedRaster(DataBuffer.TYPE_DOUBLE, width, height, 1, new Point(minx, miny)); for (int y = miny; y < miny + height; y++) { for (int x = minx; x < minx + width; x++) { rastertest.setSample(x, y, 0, val++); } } pixIterator = PixelIteratorFactory.createDefaultIterator(rastertest); interpol = new LanczosInterpolation(pixIterator, 2); }
/** * Building a synthetic image upon a FLOAT sample-model. * * @return {@linkplain BufferedImage} */ private BufferedImage getSyntheticByteImageIHSColorSpace() { final int width = 500; final int height = 500; final WritableRaster raster = RasterFactory.createBandedRaster(DataBuffer.TYPE_BYTE, width, height, 3, null); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { raster.setSample(x, y, 0, (x + y)); } } final ColorModel cm = new ComponentColorModel(new IHSColorSpaceJAIExt(), false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE); final BufferedImage image = new BufferedImage(cm, raster, false, null); return image; }
RasterFactory.createBandedRaster(DataBuffer.TYPE_INT, width, height, nValuesPerPixel, null);
public GridCoverage2D rasterize(String name, FeatureCollection<SimpleFeatureType, SimpleFeature> fc, String attributeName, IObserver observer, ReferencedEnvelope env) throws KlabException { if (raster == null) { WritableRaster raster = RasterFactory .createBandedRaster(getRasterType(observer), this.width, this.height, 1, null); setWritableRaster(raster); } clearRaster(null); if (env == null) { rasterize(fc, extent, attributeName); /* * Use full envelope from feature collection TODO check if we need to use a * buffer like in Steve's code above */ env = fc.getBounds(); } else { // /* // * TODO check if we need to use a buffer like in Steve's code above // */ // java.awt.geom.Rectangle2D.Double box = // new java.awt.geom.Rectangle2D.Double( // env.getMinX(), // env.getMinY(), // env.getWidth(), // env.getHeight()); rasterize(fc, extent, attributeName); } GridCoverage2D coverage = rasterFactory.create(name, raster, env); return coverage; }
/** * Rasterize a single shape. It is assumed that the grid and the shape agree with each * other, and that the axes don't need swapping. * * @param shape * @param value * @return rasterized coverage * @throws KlabException * */ public GridCoverage2D rasterize(ShapeValue shape, int value) throws KlabException { if (raster == null) { WritableRaster raster = RasterFactory .createBandedRaster(DataBuffer.TYPE_SHORT, this.width, this.height, 1, null); setWritableRaster(raster); } clearRaster(extent); setBounds(extent, false); this.value = value; checkReset(DataBuffer.TYPE_SHORT); addShape(shape, false); close(); GridCoverage2D coverage = rasterFactory .create(NameGenerator.newName("mask"), raster, ((Grid)extent).getEnvelope()); return coverage; }
/** * Rasterize a collection of shapes. It is assumed that the grid and the shape agree with each * other, and that the axes don't need swapping. * * @param shape * @param value * @return rasterized coverage * @throws KlabException * */ public GridCoverage2D rasterize(Collection<ShapeValue> shapes, int value) throws KlabException { if (raster == null) { WritableRaster raster = RasterFactory .createBandedRaster(DataBuffer.TYPE_SHORT, this.width, this.height, 1, null); setWritableRaster(raster); } clearRaster(extent); setBounds(extent, false); this.value = value; checkReset(DataBuffer.TYPE_SHORT); for (ShapeValue shape : shapes) { addShape(shape, false); } close(); GridCoverage2D coverage = rasterFactory .create(NameGenerator.newName("mask"), raster, ((Grid)extent).getEnvelope()); return coverage; }
rastertest = RasterFactory.createBandedRaster(DataBuffer.TYPE_DOUBLE, width, height, 1, new Point(minx, miny)); pixIterator = PixelIteratorFactory.createDefaultIterator(rastertest); interpol = new BiCubicInterpolation1(pixIterator);
width = 8; height = 8; rastertest = RasterFactory.createBandedRaster(DataBuffer.TYPE_DOUBLE, width, height, 1, new Point(minx, miny)); for (int y = miny; y < miny + height; y++) { for (int x = minx; x < minx + width; x++) {