Arrays.fill(doubleDataArray[i], noDataValue.doubleValue()); dataBuffer = new DataBufferDouble(doubleDataArray, dataBufferSize); break;
@Override protected DataBufferDouble createDataBuffer( final DoubleArray data ) { final double[] sourceArray = data.getCurrentStorageArray(); return new DataBufferDouble( sourceArray, sourceArray.length ); }
@Override protected DataBufferDouble createDataBuffer( final DoubleArray data ) { final double[] sourceArray = data.getCurrentStorageArray(); return new DataBufferDouble( sourceArray, sourceArray.length ); }
/** * Creates an image from the given double-precision floating point data. * * @param data Array containing image data. * It is assumed that each channel corresponds to one element of the array. * For example, for RGB data, data[0] is R, data[1] is G, and data[2] is B. * @param w Width of image plane. * @param h Height of image plane. */ public static BufferedImage makeImage(double[][] data, int w, int h) { int dataType = DataBuffer.TYPE_DOUBLE; DataBuffer buffer = new DataBufferDouble(data, data[0].length); return constructImage(data.length, dataType, w, h, false, true, buffer); }
/** * Creates an image from the given double-precision floating point data. * * @param data Array containing image data. * It is assumed that each channel corresponds to one element of the array. * For example, for RGB data, data[0] is R, data[1] is G, and data[2] is B. * @param w Width of image plane. * @param h Height of image plane. */ public static BufferedImage makeImage(double[][] data, int w, int h) { int dataType = DataBuffer.TYPE_DOUBLE; DataBuffer buffer = new DataBufferDouble(data, data[0].length); return constructImage(data.length, dataType, w, h, false, true, buffer); }
/** * Creates an image from the given double-precision floating point data. * * @param data Array containing image data. * It is assumed that each channel corresponds to one element of the array. * For example, for RGB data, data[0] is R, data[1] is G, and data[2] is B. * @param w Width of image plane. * @param h Height of image plane. */ public static BufferedImage makeImage(double[][] data, int w, int h) { int dataType = DataBuffer.TYPE_DOUBLE; DataBuffer buffer = new DataBufferDouble(data, data[0].length); return constructImage(data.length, dataType, w, h, false, true, buffer); }
/** * Constructs a {@linkplain GridType#LOCALIZATION localization} grid using the specified data. * This convenience method creates the intermediate {@link DataBufferDouble} object from the * supplied data assuming that the first valid values is located at index 0. If this is not * the case, user can create a {@code DataBufferDouble} object directly in order to gain more * control. * * @param width Number of columns in the grid. * @param height Number of rows in the grid. * @param data Data stored in <a href="http://en.wikipedia.org/wiki/Row-major_order">row-major * order</a>, one array for each target dimension. * @return The math transform backed by the given grid. */ public static GridTransform create(final int width, final int height, final double[]... data) { return create(GridType.LOCALIZATION, new DataBufferDouble(data, width*height), new Dimension(width, height), null); }
/** * Creates an image from the given double-precision floating point data. * * @param data Array containing image data. It is assumed that each channel * corresponds to one element of the array. For example, for RGB * data, data[0] is R, data[1] is G, and data[2] is B. * @param w Width of image plane. * @param h Height of image plane. */ public static BufferedImage makeImage(final double[][] data, final int w, final int h) { final int dataType = DataBuffer.TYPE_DOUBLE; final DataBuffer buffer = new DataBufferDouble(data, data[0].length); return constructImage(data.length, dataType, w, h, false, true, buffer); }
/** * Creates an image from the given double-precision floating point data. * * @param data Array containing image data. It is assumed that each channel * corresponds to one element of the array. For example, for RGB * data, data[0] is R, data[1] is G, and data[2] is B. * @param w Width of image plane. * @param h Height of image plane. */ public static BufferedImage makeImage(final double[][] data, final int w, final int h) { final int dataType = DataBuffer.TYPE_DOUBLE; final DataBuffer buffer = new DataBufferDouble(data, data[0].length); return constructImage(data.length, dataType, w, h, false, true, buffer); }
private static RenderedImage createRenderedImage(final double[] array, final int w, final int h) { // create rendered image with demension being width by height final SampleModel sampleModel = RasterFactory.createBandedSampleModel(DataBuffer.TYPE_DOUBLE, w, h, 1); final ColorModel colourModel = PlanarImage.createColorModel(sampleModel); final DataBufferDouble dataBuffer = new DataBufferDouble(array, array.length); final WritableRaster raster = RasterFactory.createWritableRaster(sampleModel, dataBuffer, new Point(0, 0)); return new BufferedImage(colourModel, raster, false, new Hashtable()); }
private static RenderedImage createRenderedImage(double[] array, int width, int height) { // create rendered image with dimension being width by height final SampleModel sampleModel = RasterFactory.createBandedSampleModel(DataBuffer.TYPE_DOUBLE, width, height, 1); final ColorModel colourModel = PlanarImage.createColorModel(sampleModel); final DataBufferDouble dataBuffer = new DataBufferDouble(array, array.length); final WritableRaster raster = RasterFactory.createWritableRaster(sampleModel, dataBuffer, new java.awt.Point(0, 0)); return new BufferedImage(colourModel, raster, false, new Hashtable()); }
private static RenderedImage createRenderedImage(final double[] array, final int width, final int height) { // create rendered image with demension being width by height final SampleModel sampleModel = RasterFactory.createBandedSampleModel(DataBuffer.TYPE_DOUBLE, width, height, 1); final ColorModel colourModel = PlanarImage.createColorModel(sampleModel); final DataBufferDouble dataBuffer = new DataBufferDouble(array, array.length); final WritableRaster raster = RasterFactory.createWritableRaster(sampleModel, dataBuffer, new Point(0, 0)); return new BufferedImage(colourModel, raster, false, new Hashtable()); }
private static RenderedImage createRenderedImage(final double[] array, final int w, final int h) { // create rendered image with dimension being width by height final SampleModel sampleModel = RasterFactory.createBandedSampleModel(DataBuffer.TYPE_DOUBLE, w, h, 1); final ColorModel colourModel = PlanarImage.createColorModel(sampleModel); final DataBufferDouble dataBuffer = new DataBufferDouble(array, array.length); final WritableRaster raster = RasterFactory.createWritableRaster(sampleModel, dataBuffer, new Point(0, 0)); return new BufferedImage(colourModel, raster, false, null); }
/** * Creates an image from the given double data. * * @param data Array containing image data. * @param w Width of image plane. * @param h Height of image plane. * @param c Number of channels. * @param interleaved If set, the channels are assumed to be interleaved; * otherwise they are assumed to be sequential. For example, for RGB * data, the pattern "RGBRGBRGB..." is interleaved, while * "RRR...GGG...BBB..." is sequential. */ public static BufferedImage makeImage(final double[] data, final int w, final int h, final int c, final boolean interleaved) { if (c == 1) return makeImage(data, w, h); final int dataType = DataBuffer.TYPE_DOUBLE; final DataBuffer buffer = new DataBufferDouble(data, c * w * h); return constructImage(c, dataType, w, h, interleaved, false, buffer); }
/** * Creates an image from the given double data. * * @param data Array containing image data. * @param w Width of image plane. * @param h Height of image plane. * @param c Number of channels. * @param interleaved If set, the channels are assumed to be interleaved; * otherwise they are assumed to be sequential. * For example, for RGB data, the pattern "RGBRGBRGB..." is interleaved, * while "RRR...GGG...BBB..." is sequential. */ public static BufferedImage makeImage(double[] data, int w, int h, int c, boolean interleaved) { if (c == 1) return makeImage(data, w, h); int dataType = DataBuffer.TYPE_DOUBLE; DataBuffer buffer = new DataBufferDouble(data, c * w * h); return constructImage(c, dataType, w, h, interleaved, false, buffer); }
/** * Creates an image from the given double data. * * @param data Array containing image data. * @param w Width of image plane. * @param h Height of image plane. * @param c Number of channels. * @param interleaved If set, the channels are assumed to be interleaved; * otherwise they are assumed to be sequential. * For example, for RGB data, the pattern "RGBRGBRGB..." is interleaved, * while "RRR...GGG...BBB..." is sequential. */ public static BufferedImage makeImage(double[] data, int w, int h, int c, boolean interleaved) { if (c == 1) return makeImage(data, w, h); int dataType = DataBuffer.TYPE_DOUBLE; DataBuffer buffer = new DataBufferDouble(data, c * w * h); return constructImage(c, dataType, w, h, interleaved, false, buffer); }
/** * Creates an image from the given double data. * * @param data Array containing image data. * @param w Width of image plane. * @param h Height of image plane. * @param c Number of channels. * @param interleaved If set, the channels are assumed to be interleaved; * otherwise they are assumed to be sequential. For example, for RGB * data, the pattern "RGBRGBRGB..." is interleaved, while * "RRR...GGG...BBB..." is sequential. */ public static BufferedImage makeImage(final double[] data, final int w, final int h, final int c, final boolean interleaved) { if (c == 1) return makeImage(data, w, h); final int dataType = DataBuffer.TYPE_DOUBLE; final DataBuffer buffer = new DataBufferDouble(data, c * w * h); return constructImage(c, dataType, w, h, interleaved, false, buffer); }
@Override public BufferedImage getRemoteBufferedImage(){ SampleModel samplemodel = new BandedSampleModel(DataBuffer.TYPE_DOUBLE, getWidth(), getHeight(), hasAlpha() ? 4:3); DataBufferDouble databuffer = new DataBufferDouble(getData(), numValues()); WritableRaster raster = Raster.createWritableRaster(samplemodel, databuffer, null); ColorModel colormodel = new ComponentColorModel( ColorSpace.getInstance(ColorSpace.CS_sRGB), hasAlpha(), false, hasAlpha() ? ComponentColorModel.TRANSLUCENT:ComponentColorModel.OPAQUE, DataBuffer.TYPE_DOUBLE ); BufferedImage bimg = new BufferedImage(colormodel, raster, false, null); return bimg; }
@Test public void testAccumulateDataDoubleWithNegativeValues() throws Exception { double[] data = new double[]{-1.6, -1.7, -1.8, -1.9, -2.0, -2.1, -2.2, -2.3, -2.4, -2.5, -2.6}; RenderedImage image = new BufferedOpImage(new DataBufferDouble(data, data.length)); SummaryStxOp op = new SummaryStxOp(); op.accumulateData(getPixels(image), null); assertEquals(-2.6, op.getMinimum(), 1.0e-8); assertEquals(-1.6, op.getMaximum(), 1.0e-8); assertEquals(-2.1, op.getMean(), 1.0e-8); assertEquals(0.11, op.getVariance(), 1.0e-8); assertEquals(0.33166247, op.getStandardDeviation(), 1.0e-8); }
@Test public void testAccumulateDataDouble() throws Exception { double[] data = new double[]{18.6, 18.7, 18.8, 18.9, 19.0, 19.1, 19.2, 19.3, 19.4, 19.5, 19.6}; SummaryStxOp op = new SummaryStxOp(); op.accumulateData(getPixels(new DataBufferDouble(data, data.length)), null); assertEquals(18.6, op.getMinimum(), 1.0e-8); assertEquals(19.6, op.getMaximum(), 1.0e-8); assertEquals(19.1, op.getMean(), 1.0e-8); assertEquals(0.11, op.getVariance(), 1.0e-8); assertEquals(0.33166247, op.getStandardDeviation(), 1.0e-8); }