Java Code Examples for java.awt.image.Raster#getSampleDouble()
The following examples show how to use
java.awt.image.Raster#getSampleDouble() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Calibration.java From orbit-image-analysis with GNU General Public License v3.0 | 6 votes |
public List<double[]> getPairs(BufferedImage bi1, BufferedImage bi2, int u, int v, int s, int n) throws IOException { List<double[]> pairList = new ArrayList<>(bi1.getWidth()*bi1.getHeight()); Raster r1 = bi1.getRaster().createTranslatedChild(0,0); Raster r2 = bi2.getRaster().createTranslatedChild(0,0); if (r1.getNumBands()>1) throw new IllegalArgumentException("only 1-banded rasters allowed here"); if (r2.getNumBands()>1) throw new IllegalArgumentException("only 1-banded rasters allowed here"); SimpleRegression reg = new SimpleRegression(true); int minX = u<0?u*-1:0; int minY = v<0?v*-1:0; int maxX = u>0?bi1.getWidth()-u: bi1.getWidth(); int maxY = v>0?bi1.getHeight()-v: bi1.getHeight(); for (int x=minX; x<maxX; x++) { for (int y=minY; y<maxY; y++) { double d1 = r1.getSampleDouble(x+u,y+v,0); if (d1> intensityThreshold) { double d2 = r2.getSampleDouble(x, y, 0); double[] pair = new double[]{d2,d1}; pairList.add(pair); } } } return pairList; }
Example 2
Source File: Calibration.java From orbit-image-analysis with GNU General Public License v3.0 | 6 votes |
public double getSlope(BufferedImage bi1, BufferedImage bi2, int u, int v, int s, int n) throws IOException { Raster r1 = bi1.getRaster().createTranslatedChild(0,0); Raster r2 = bi2.getRaster().createTranslatedChild(0,0); if (r1.getNumBands()>1) throw new IllegalArgumentException("only 1-banded rasters allowed here"); if (r2.getNumBands()>1) throw new IllegalArgumentException("only 1-banded rasters allowed here"); SimpleRegression reg = new SimpleRegression(true); int minX = u<0?u*-1:0; int minY = v<0?v*-1:0; int maxX = u>0?bi1.getWidth()-u: bi1.getWidth(); int maxY = v>0?bi1.getHeight()-v: bi1.getHeight(); for (int x=minX; x<maxX; x++) { for (int y=minY; y<maxY; y++) { double d1 = r1.getSampleDouble(x+u,y+v,0); if (d1> intensityThreshold) { double d2 = r2.getSampleDouble(x, y, 0); reg.addData(d2, d1); } } } double slope = reg.getSlope(); double intercept = reg.getIntercept(); logger.info("i,j: "+s+","+n+": "+ "slope: "+slope+" ; intercept: "+intercept); return slope; }
Example 3
Source File: CsvExporter.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
static double getValue(RasterDataNode raster, int pixelX, int pixelY, int currentLevel) { final RenderedImage image = raster.getGeophysicalImage().getImage(currentLevel); final Rectangle pixelRect = new Rectangle(pixelX, pixelY, 1, 1); final Raster data = image.getData(pixelRect); final MultiLevelImage validMaskImage = raster.getValidMaskImage(); Raster validMaskData = null; if (validMaskImage != null) { final RenderedImage validMask = validMaskImage.getImage(currentLevel); validMaskData = validMask.getData(pixelRect); } final double value; if (validMaskData == null || validMaskData.getSample(pixelX, pixelY, 0) > 0) { value = data.getSampleDouble(pixelX, pixelY, 0); } else { value = Double.NaN; } return value; }
Example 4
Source File: MaskComposite.java From mrgeo with Apache License 2.0 | 5 votes |
@Override public void compose(Raster src, Raster dstIn, WritableRaster dstOut) { int minX = dstOut.getMinX(); int minY = dstOut.getMinY(); int maxX = minX + dstOut.getWidth(); int maxY = minY + dstOut.getHeight(); for (int y = minY; y < maxY; y++) { for (int x = minX; x < maxX; x++) { double srcValue = src.getSampleDouble(x, y, 0); // If the source value is set to the srcMaskedValue, then write out // the maskedValue. Otherwise, write out the unmaskedValue. if (((srcMaskedValue - EPSILON) <= srcValue) && (srcValue <= (srcMaskedValue + EPSILON))) { // dstOut.setSample(x, y, 0, maskedValue); dstOut.setSample(x, y, 0, maskedValue); } else { dstOut.setSample(x, y, 0, unmaskedValue); } } } }
Example 5
Source File: AdditiveCompositeDouble.java From mrgeo with Apache License 2.0 | 5 votes |
@Override public void compose(Raster src, Raster dstIn, WritableRaster dstOut) { int minX = dstOut.getMinX(); int minY = dstOut.getMinY(); int maxX = minX + dstOut.getWidth(); int maxY = minY + dstOut.getHeight(); //log.debug("minX,minY,maxX,maxY: " + minX + "," + minY + "," + maxX + "," + maxY); for (int y = minY; y < maxY; y++) { for (int x = minX; x < maxX; x++) { double d = dstIn.getSampleDouble(x, y, 0); if (isNodataNaN) { if (Double.isNaN(d)) { d = 0; } } else { if (FloatUtils.isEqual(d, nodata)) { d = 0; } } double sample = (src.getSampleDouble(x, y, 0) * weight) + d; dstOut.setSample(x, y, 0, sample); } } }
Example 6
Source File: BufferedGridCoverageTest.java From sis with Apache License 2.0 | 5 votes |
/** * assert that the sample values in the given coverage are equal to the expected values. */ private static void assertSamplesEqual(final GridCoverage coverage, final double[][] expected) { final Raster raster = coverage.render(null).getData(); for (int y=0; y<expected.length; y++) { for (int x=0; x<expected[y].length; x++) { double value = raster.getSampleDouble(x, y, 0); Assert.assertEquals(expected[y][x], value, STRICT); } } }
Example 7
Source File: GaussianComposite.java From mrgeo with Apache License 2.0 | 4 votes |
@Override public void compose(Raster src, Raster dstIn, WritableRaster dstOut) { int minX = dstOut.getMinX(); int minY = dstOut.getMinY(); int maxX = minX + dstOut.getWidth(); int maxY = minY + dstOut.getHeight(); //System.out.println(minX + ", " + minY + " - " + maxX + ", " + maxY); // calculate the area of the ellipse double area = Math.PI * (major / 2.0) * (minor / 2.0); // the final pixel multiplier, to be combined with the gaussian double multiplier = weight / area; for (int y = minY; y < maxY; y++) { for (int x = minX; x < maxX; x++) { double d = dstIn.getSampleDouble(x, y, 0); double s = src.getSampleDouble(x, y, 0); double sample; if (isNodataNaN) { if (Double.isNaN(s)) { sample = d; } else { // do the gaussian... sample = calculateGaussian(s, x - dstIn.getSampleModelTranslateX(), y - dstIn.getSampleModelTranslateY(), multiplier); } } else { if (FloatUtils.isEqual(s, nodata)) { sample = d; } else { // do the gaussian... sample = calculateGaussian(s, x - dstIn.getSampleModelTranslateX(), y - dstIn.getSampleModelTranslateY(), multiplier); } } dstOut.setSample(x, y, 0, sample); } } }
Example 8
Source File: MinCompositeDouble.java From mrgeo with Apache License 2.0 | 4 votes |
@Override public void compose(Raster src, Raster dstIn, WritableRaster dstOut) { int minX = dstOut.getMinX(); int minY = dstOut.getMinY(); int maxX = minX + dstOut.getWidth(); int maxY = minY + dstOut.getHeight(); //log.debug("minX,minY,maxX,maxY: " + minX + "," + minY + "," + maxX + "," + maxY); for (int y = minY; y < maxY; y++) { for (int x = minX; x < maxX; x++) { double d = dstIn.getSampleDouble(x, y, 0); double s = src.getSampleDouble(x, y, 0) * weight; double sample; if (isNodataNaN) { if (Double.isNaN(d)) { sample = s; } else if (Double.isNaN(s)) { sample = d; } else if (s < d) { sample = s; } else { sample = d; } } else { if (FloatUtils.isEqual(d, nodata)) { sample = s; } else if (FloatUtils.isEqual(s, nodata)) { sample = d; } else if (s < d) { sample = s; } else { sample = d; } } dstOut.setSample(x, y, 0, sample); } } }
Example 9
Source File: MaxCompositeDouble.java From mrgeo with Apache License 2.0 | 4 votes |
@Override public void compose(Raster src, Raster dstIn, WritableRaster dstOut) { int minX = dstOut.getMinX(); int minY = dstOut.getMinY(); int maxX = minX + dstOut.getWidth(); int maxY = minY + dstOut.getHeight(); //log.debug("minX,minY,maxX,maxY: " + minX + "," + minY + "," + maxX + "," + maxY); for (int y = minY; y < maxY; y++) { for (int x = minX; x < maxX; x++) { double d = dstIn.getSampleDouble(x, y, 0); double s = src.getSampleDouble(x, y, 0) * weight; double sample; if (isNodataNaN) { if (Double.isNaN(d)) { sample = s; } else if (Double.isNaN(s)) { sample = d; } else if (s > d) { sample = s; } else { sample = d; } } else { if (FloatUtils.isEqual(d, nodata)) { sample = s; } else if (FloatUtils.isEqual(s, nodata)) { sample = d; } else if (s > d) { sample = s; } else { sample = d; } } dstOut.setSample(x, y, 0, sample); } } }