/** * Returns the sample in a specified band for a pixel located at (x,y) as a <code>double</code>. * <code>ArrayIndexOutOfBoundsException</code> may be thrown if the coordinates are not in * bounds. * * @param x The X coordinate of the pixel location. * @param y The Y coordinate of the pixel location. * @param b The band to return. * @param data The <code>DataBuffer</code> containing the image data. * @return sample The <code>double</code> sample value * @throws <code>ArrayIndexOutOfBoundsException</code> if coordinates are not in bounds */ public double getSampleDouble(int x, int y, int b, DataBuffer data) { double sample = data.getElemDouble(bankIndices[b], y * scanlineStride + x * pixelStride + bandOffsets[b]); return sample; }
/** * @inheritDoc */ @Override public double getSampleDouble(int x, int y, int b, DataBuffer data) { checkBounds(x, y); return data.getElemDouble(y * width + x); }
final double dy = yi - row; for (int j=0; j<dstDim; j++) { final double v00 = (grid.getElemDouble(j, offset00)); final double v01 = (grid.getElemDouble(j, offset01)); final double v0 = (grid.getElemDouble(j, offset10) - v00) * dx + v00; final double v1 = (grid.getElemDouble(j, offset11) - v01) * dx + v01; double value = v0 + (v1-v0) * dy; switch (type) {
final Matrix derivative = derivate ? Matrices.createDiagonal(dstDim, srcDim) : null; for (int j=0; j<dstDim; j++) { final double v00 = (grid.getElemDouble(j, offset00)); final double v01 = (grid.getElemDouble(j, offset01)); final double v10 = (grid.getElemDouble(j, offset10)); final double v11 = (grid.getElemDouble(j, offset11)); if (derivative != null) { double dxj = (v10 - v00); dxj += ((v11 - v01) - dxj) * dy;
for (int b=0; b<dstDim; b++) { for (int i=0; i<size; i++) { final double va = this.grid.getElemDouble(b,i); final double vb = that.grid.getElemDouble(b,i); if (!Utilities.equals(va, vb)) { return false;
elem = buffer.getElemFloat(index); } else if (type == DataBuffer.TYPE_DOUBLE) { elem = buffer.getElemDouble(index); } else { throw new IllegalArgumentException("Undefined band data type '" + type + "' in source product."); elem = buffer.getElemFloat(index); } else if (type == DataBuffer.TYPE_DOUBLE) { elem = buffer.getElemDouble(index); } else { throw new IllegalArgumentException("Undefined tie point grid data type '" + type + "' in source product.");
ddata[i] = data.getElemDouble(bankIndices[i], pixelOffset + bandOffsets[i]);
private static void testTileData(Raster tile, double[] coefficients) { final DataBuffer dataBuffer = tile.getDataBuffer(); assertEquals(TILE_SIZE * TILE_SIZE, dataBuffer.getSize()); for (int dbIndex = 0, pdIndex = 0; dbIndex < dataBuffer.getSize(); dbIndex++) { final int x = tile.getMinX() + dbIndex % tile.getWidth(); final int y = tile.getMinY() + dbIndex / tile.getWidth(); final double actual = dataBuffer.getElemDouble(dbIndex); if (x >= 0 && x < IMAGE_W && y >= 0 && y < IMAGE_H) { final double expected = coefficients[0] * pdIndex + coefficients[1]; assertEquals("Inside image bounds: dataBuffer.getElemDouble(" + dbIndex + ")", expected, actual, 0.0); pdIndex++; } else { assertEquals("Outside image bounds: dataBuffer.getElemDouble(" + dbIndex + ")", 0.0, actual, 0.0); } } }
@Override protected void computeRect(PlanarImage[] sources, WritableRaster dest, Rectangle destRect) { for (int y = 0; y < destRect.height; y++) { for (int x = 0; x < destRect.width; x++) { if (dataBuffer.getDataType() == DataBuffer.TYPE_FLOAT) { dest.setSample(x, y, 0, dataBuffer.getElemFloat(y * destRect.width + x)); } else if (dataBuffer.getDataType() == DataBuffer.TYPE_DOUBLE) { dest.setSample(x, y, 0, dataBuffer.getElemDouble(y * destRect.width + x)); } else { dest.setSample(x, y, 0, dataBuffer.getElem(y * destRect.width + x)); } } } } }