Package javax.media.jai.iterator

Examples of javax.media.jai.iterator.RectIter


    // // TODO: got 700 (rather than 650) on mac osx
    // checkMatrixEqual(scaledJAIImage, mapDataAfter, 0.0);
    // }

    protected void checkMatrixEqual( RenderedImage image, double[][] matrix, double delta ) {
        RectIter rectIter = RectIterFactory.create(image, null);
        int y = 0;
        do {
            int x = 0;
            do {
                double value = rectIter.getSampleDouble();
                double expectedResult = matrix[y][x];
                if (Double.isNaN(value)) {
                    assertTrue(x + " " + y, Double.isNaN(expectedResult));
                } else {
                    assertEquals(x + " " + y, expectedResult, value, delta);
                }
                x++;
            } while( !rectIter.nextPixelDone() );
            rectIter.startPixels();
            y++;
        } while( !rectIter.nextLineDone() );
    }
View Full Code Here


        assertEquals(10, width);
        return gc;
    }

    protected void checkMatrixEqual( RenderedImage image, double[][] matrix, double delta ) {
        RectIter rectIter = RectIterFactory.create(image, null);
        int y = 0;
        do {
            int x = 0;
            do {
                double value = rectIter.getSampleDouble();
                double expectedResult = matrix[y][x];
                if (Double.isNaN(value)) {
                    assertTrue(x + " " + y, Double.isNaN(expectedResult));
                } else {
                    assertEquals(x + " " + y, expectedResult, value, delta);
                }
                x++;
            } while( !rectIter.nextPixelDone() );
            rectIter.startPixels();
            y++;
        } while( !rectIter.nextLineDone() );
    }
View Full Code Here

        GridCoverage2D readCoverage = read(grassFile, r, crs32632);
        checkMatrixEqual(readCoverage.getRenderedImage(), mapData, 0);
    }

    protected void printImage( RenderedImage image ) {
        RectIter rectIter = RectIterFactory.create(image, null);
        int y = 0;
        do {
            int x = 0;
            do {
                double value = rectIter.getSampleDouble();
                System.out.print(value + " ");
                x++;
            } while( !rectIter.nextPixelDone() );
            rectIter.startPixels();
            y++;
            System.out.println();
        } while( !rectIter.nextLineDone() );
    }
View Full Code Here

        // readgrassraster stop
        return gc;
    }

    protected void checkMatrixEqual( RenderedImage image, double[][] matrix, double delta ) {
        RectIter rectIter = RectIterFactory.create(image, null);
        int y = 0;
        do {
            int x = 0;
            do {
                double value = rectIter.getSampleDouble();
                double expectedResult = matrix[y][x];
                if (Double.isNaN(value)) {
                    assertTrue(x + " " + y, Double.isNaN(expectedResult));
                } else {
                    assertEquals(x + " " + y, expectedResult, value, delta);
                }
                x++;
            } while( !rectIter.nextPixelDone() );
            rectIter.startPixels();
            y++;
        } while( !rectIter.nextLineDone() );
    }
View Full Code Here

        RenderedImage renderedImage = coverage2D.getRenderedImage();
        printImage(renderedImage);
    }

    public static void printImage( RenderedImage renderedImage ) {
        RectIter rectIter = RectIterFactory.create(renderedImage, null);
        int y = 0;
        do {
            int x = 0;
            do {
                double value = rectIter.getSampleDouble();
                System.out.print(value + " ");
                x++;
            } while( !rectIter.nextPixelDone() );
            rectIter.startPixels();
            y++;
            System.out.println();
        } while( !rectIter.nextLineDone() );
    }
View Full Code Here

     * Dump the float values in a (small) grid coverage to the console
     */
    private void textPrintFloat(GridCoverage2D cov) {
        RenderedImage img = cov.getRenderedImage();
        int nb = img.getSampleModel().getNumBands();
        RectIter iter = RectIterFactory.create(img, null);
        float[] pixel = new float[nb];
        do {
            do {
                iter.getPixel(pixel);
                for (int i = 0; i < nb; i++) {
                    System.out.print(pixel[i]);
                }
            } while (!iter.nextPixelDone());
            iter.startPixels();
            System.out.println();
        } while (!iter.nextLineDone());
    }
View Full Code Here

     * Dump the int values in a (small) grid coverage to the console
     */
    private void textPrint(GridCoverage2D cov) {
        RenderedImage img = cov.getRenderedImage();
        int nb = img.getSampleModel().getNumBands();
        RectIter iter = RectIterFactory.create(img, null);
        int[] pixel = new int[nb];
        int w = img.getWidth();
        do {
            do {
                iter.getPixel(pixel);
                for (int i = 0; i < nb; i++) {
                    System.out.print(pixel[i]);
                }
            } while (!iter.nextPixelDone());
            iter.startPixels();
            System.out.println();
        } while (!iter.nextLineDone());
    }
View Full Code Here

     *
     * @param expected The image containing the expected pixel values.
     * @param actual   The image containing the actual pixel values.
     */
    protected static void assertRasterEquals(final RenderedImage expected, final RenderedImage actual) {
        final RectIter e = RectIterFactory.create(expected, null);
        final RectIter a = RectIterFactory.create(actual,   null);
        if (!e.finishedLines()) do {
            assertFalse(a.finishedLines());
            if (!e.finishedPixels()) do {
                assertFalse(a.finishedPixels());
                if (!e.finishedBands()) do {
                    assertFalse(a.finishedBands());
                    final float pe = e.getSampleFloat();
                    final float pa = a.getSampleFloat();
                    assertEquals(pe, pa, EPS);
                    a.nextBand();
                } while (!e.nextBandDone());
                assertTrue(a.finishedBands());
                a.nextPixel();
                a.startBands();
                e.startBands();
            } while (!e.nextPixelDone());
            assertTrue(a.finishedPixels());
            a.nextLine();
            a.startPixels();
            e.startPixels();
        } while (!e.nextLineDone());
        assertTrue(a.finishedLines());
    }
View Full Code Here

       * may be important. But it seems to still lower than query tiles
       * many time (which may involve more computation than necessary).
       */
      bounds.x = ix - left;
      bounds.y = iy - top;
      final RectIter iter = RectIterFactory.create(image.getExtendedData(bounds, this.borderExtender), bounds);
      for (; band<bandUp; band++) {
          iter.startLines();
          int j=0; do {
              iter.startPixels();
              final double[] row=samples[j++];
              int i=0; do {
                  row[i++] = iter.getSampleDouble(band);
              }
              while (!iter.nextPixelDone());
              assert i == row.length;
          }
          while (!iter.nextLineDone());
          assert j == samples.length;
          float dx = (float)(x-x0); if (dx==1) dx=ONE_EPSILON;
          float dy = (float)(y-y0); if (dy==1) dy=ONE_EPSILON;
          final double value = interpolation.interpolate(samples, dx, dy);
          if (Double.isNaN(value)) {
View Full Code Here

       * may be important. But it seems to still lower than query tiles
       * many time (which may involve more computation than necessary).
       */
      bounds.x = ix - left;
      bounds.y = iy - top;
      final RectIter iter = RectIterFactory.create(image.getExtendedData(bounds, this.borderExtender), bounds);
      for (; band<bandUp; band++) {
          iter.startLines();
          int j=0; do {
              iter.startPixels();
              final float[] row=samples[j++];
              int i=0; do {
                  row[i++] = iter.getSampleFloat(band);
              }
              while (!iter.nextPixelDone());
              assert i == row.length;
          }
          while (!iter.nextLineDone());
          assert j == samples.length;
          float dx = (float)(x-x0); if (dx==1) dx=ONE_EPSILON;
          float dy = (float)(y-y0); if (dy==1) dy=ONE_EPSILON;
          final float value = interpolation.interpolate(samples, dx, dy);
          if (Float.isNaN(value)) {
View Full Code Here

TOP

Related Classes of javax.media.jai.iterator.RectIter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.