Examples of RandomIter


Examples of javax.media.jai.iterator.RandomIter

            }
        }
    }

    private void computeRectInt(PlanarImage src, RasterAccessor dst) {
        RandomIter iter;
        if(extender != null) {
            Rectangle bounds = new Rectangle(src.getMinX(), src.getMinY(),
                                             src.getWidth() + 1,
                                             src.getHeight() + 1);
            iter = RandomIterFactory.create(src.getExtendedData(bounds,
                                                                extender),
                                            bounds);
        } else {
            iter = RandomIterFactory.create(src, src.getBounds());
        }

        int minX = src.getMinX();
        int maxX = src.getMaxX() -
            (extender != null ? 0 : 1); // Right padding
        int minY = src.getMinY();
        int maxY = src.getMaxY() -
            (extender != null ? 0 : 1); // Bottom padding

        int dstWidth = dst.getWidth();
        int dstHeight = dst.getHeight();
        int dstBands = dst.getNumBands();

        int lineStride = dst.getScanlineStride();
        int pixelStride = dst.getPixelStride();
        int[] bandOffsets = dst.getBandOffsets();
        int[][] data = dst.getIntDataArrays();

        float[] warpData = new float[2 * dstWidth];

        int lineOffset = 0;

  int[] backgroundInt = new int[dstBands];
  for (int i = 0; i < dstBands; i++)
      backgroundInt[i] = (int)backgroundValues[i];

        for (int h = 0; h < dstHeight; h++) {
            int pixelOffset = lineOffset;
            lineOffset += lineStride;

            warp.warpRect(dst.getX(), dst.getY()+h, dstWidth, 1,
                          warpData);
            int count = 0;
            for (int w = 0; w < dstWidth; w++) {
                float sx = warpData[count++];
                float sy = warpData[count++];

                int xint = floor(sx);
                int yint = floor(sy);
                float xfrac = sx - xint;
                float yfrac = sy - yint;

                if (xint < minX || xint >= maxX ||
                    yint < minY || yint >= maxY) {
                    /* Fill with a background color. */
                    if (setBackground) {
                        for (int b = 0; b < dstBands; b++) {
                            data[b][pixelOffset+bandOffsets[b]] =
                                backgroundInt[b];
                        }
                    }
                } else {
                    for (int b = 0; b < dstBands; b++) {
                        int s00 = iter.getSample(xint, yint, b);
                        int s01 = iter.getSample(xint+1, yint, b);
                        int s10 = iter.getSample(xint, yint+1, b);
                        int s11 = iter.getSample(xint+1, yint+1, b);

                        float s0 = (s01 - s00) * xfrac + s00;
                        float s1 = (s11 - s10) * xfrac + s10;
                        float s = (s1 - s0) * yfrac + s0;

View Full Code Here

Examples of javax.media.jai.iterator.RandomIter

            }
        }
    }

    private void computeRectFloat(PlanarImage src, RasterAccessor dst) {
        RandomIter iter;
        if(extender != null) {
            Rectangle bounds = new Rectangle(src.getMinX(), src.getMinY(),
                                             src.getWidth() + 1,
                                             src.getHeight() + 1);
            iter = RandomIterFactory.create(src.getExtendedData(bounds,
                                                                extender),
                                            bounds);
        } else {
            iter = RandomIterFactory.create(src, src.getBounds());
        }

        int minX = src.getMinX();
        int maxX = src.getMaxX() -
            (extender != null ? 0 : 1); // Right padding
        int minY = src.getMinY();
        int maxY = src.getMaxY() -
            (extender != null ? 0 : 1); // Bottom padding

        int dstWidth = dst.getWidth();
        int dstHeight = dst.getHeight();
        int dstBands = dst.getNumBands();

        int lineStride = dst.getScanlineStride();
        int pixelStride = dst.getPixelStride();
        int[] bandOffsets = dst.getBandOffsets();
        float[][] data = dst.getFloatDataArrays();

        float[] warpData = new float[2 * dstWidth];

        int lineOffset = 0;

  float[] backgroundFloat = new float[dstBands];
  for (int i = 0; i < dstBands; i++)
      backgroundFloat[i] = (float)backgroundValues[i];

        for (int h = 0; h < dstHeight; h++) {
            int pixelOffset = lineOffset;
            lineOffset += lineStride;

            warp.warpRect(dst.getX(), dst.getY()+h, dstWidth, 1,
                          warpData);
            int count = 0;
            for (int w = 0; w < dstWidth; w++) {
                float sx = warpData[count++];
                float sy = warpData[count++];

                int xint = floor(sx);
                int yint = floor(sy);
                float xfrac = sx - xint;
                float yfrac = sy - yint;

                if (xint < minX || xint >= maxX ||
                    yint < minY || yint >= maxY) {
                    /* Fill with a background color. */
                    if (setBackground) {
                        for (int b = 0; b < dstBands; b++) {
                            data[b][pixelOffset+bandOffsets[b]] =
                                backgroundFloat[b];
                        }
                    }
                } else {
                    for (int b = 0; b < dstBands; b++) {
                        float s00 = iter.getSampleFloat(xint, yint, b);
                        float s01 = iter.getSampleFloat(xint+1, yint, b);
                        float s10 = iter.getSampleFloat(xint, yint+1, b);
                        float s11 = iter.getSampleFloat(xint+1, yint+1, b);

                        float s0 = (s01 - s00) * xfrac + s00;
                        float s1 = (s11 - s10) * xfrac + s10;
                        float s = (s1 - s0) * yfrac + s0;

View Full Code Here

Examples of javax.media.jai.iterator.RandomIter

            }
        }
    }

    private void computeRectDouble(PlanarImage src, RasterAccessor dst) {
        RandomIter iter;
        if(extender != null) {
            Rectangle bounds = new Rectangle(src.getMinX(), src.getMinY(),
                                             src.getWidth() + 1,
                                             src.getHeight() + 1);
            iter = RandomIterFactory.create(src.getExtendedData(bounds,
                                                                extender),
                                            bounds);
        } else {
            iter = RandomIterFactory.create(src, src.getBounds());
        }

        int minX = src.getMinX();
        int maxX = src.getMaxX() -
            (extender != null ? 0 : 1); // Right padding
        int minY = src.getMinY();
        int maxY = src.getMaxY() -
            (extender != null ? 0 : 1); // Bottom padding

        int dstWidth = dst.getWidth();
        int dstHeight = dst.getHeight();
        int dstBands = dst.getNumBands();

        int lineStride = dst.getScanlineStride();
        int pixelStride = dst.getPixelStride();
        int[] bandOffsets = dst.getBandOffsets();
        double[][] data = dst.getDoubleDataArrays();

        float[] warpData = new float[2 * dstWidth];

        int lineOffset = 0;

        for (int h = 0; h < dstHeight; h++) {
            int pixelOffset = lineOffset;
            lineOffset += lineStride;

            warp.warpRect(dst.getX(), dst.getY()+h, dstWidth, 1,
                          warpData);
            int count = 0;
            for (int w = 0; w < dstWidth; w++) {
                float sx = warpData[count++];
                float sy = warpData[count++];

                int xint = floor(sx);
                int yint = floor(sy);
                float xfrac = sx - xint;
                float yfrac = sy - yint;

                if (xint < minX || xint >= maxX ||
                    yint < minY || yint >= maxY) {
                    /* Fill with a background color. */
                    if (setBackground) {
                        for (int b = 0; b < dstBands; b++) {
                            data[b][pixelOffset+bandOffsets[b]] =
                                backgroundValues[b];
                        }
                    }
                } else {
                    for (int b = 0; b < dstBands; b++) {
                        double s00 = iter.getSampleDouble(xint, yint, b);
                        double s01 = iter.getSampleDouble(xint+1, yint, b);
                        double s10 = iter.getSampleDouble(xint, yint+1, b);
                        double s11 = iter.getSampleDouble(xint+1, yint+1, b);

                        double s0 = (s01 - s00) * xfrac + s00;
                        double s1 = (s11 - s10) * xfrac + s10;
                        double s = (s1 - s0) * yfrac + s0;

View Full Code Here

Examples of javax.media.jai.iterator.RandomIter

            d.copyDataToRaster();
        }
    }

    private void computeRectByte(PlanarImage src, RasterAccessor dst) {
        RandomIter iter = RandomIterFactory.create(src, src.getBounds());

        int minX = src.getMinX();
        int maxX = src.getMaxX();
        int minY = src.getMinY();
        int maxY = src.getMaxY();

        int dstWidth = dst.getWidth();
        int dstHeight = dst.getHeight();
        int dstBands = dst.getNumBands();

        int lineStride = dst.getScanlineStride();
        int pixelStride = dst.getPixelStride();
        int[] bandOffsets = dst.getBandOffsets();
        byte[][] data = dst.getByteDataArrays();

        float[] warpData = new float[2 * dstWidth];

        int lineOffset = 0;

  byte[] backgroundByte = new byte[dstBands];
  for (int i = 0; i < dstBands; i++)
      backgroundByte[i] = (byte)backgroundValues[i];

        for (int h = 0; h < dstHeight; h++) {
            int pixelOffset = lineOffset;
            lineOffset += lineStride;

            warp.warpRect(dst.getX(), dst.getY()+h, dstWidth, 1,
                          warpData);
            int count = 0;
            for (int w = 0; w < dstWidth; w++) {
                /*
                 * The warp object subtract 0.5 from backward mapped
                 * source coordinate. Need to do a round to get the
                 * nearest neighbor. This is different from the standard
                 * nearest implementation.
                 */
                int sx = round(warpData[count++]);
                int sy = round(warpData[count++]);

                if (sx < minX || sx >= maxX || sy < minY || sy >= maxY) {
                    /* Fill with a background color. */
                    if (setBackground) {
                        for (int b = 0; b < dstBands; b++) {
                            data[b][pixelOffset+bandOffsets[b]] =
                                backgroundByte[b];
                        }
                    }
                } else {
                    for (int b = 0; b < dstBands; b++) {
                        data[b][pixelOffset+bandOffsets[b]] =
                            (byte)(iter.getSample(sx, sy, b) & 0xFF);
                    }
                }

                pixelOffset += pixelStride;
            }
View Full Code Here

Examples of javax.media.jai.iterator.RandomIter

            }
        }
    }

    private void computeRectUShort(PlanarImage src, RasterAccessor dst) {
        RandomIter iter = RandomIterFactory.create(src, src.getBounds());

        int minX = src.getMinX();
        int maxX = src.getMaxX();
        int minY = src.getMinY();
        int maxY = src.getMaxY();

        int dstWidth = dst.getWidth();
        int dstHeight = dst.getHeight();
        int dstBands = dst.getNumBands();

        int lineStride = dst.getScanlineStride();
        int pixelStride = dst.getPixelStride();
        int[] bandOffsets = dst.getBandOffsets();
        short[][] data = dst.getShortDataArrays();

        float[] warpData = new float[2 * dstWidth];

        int lineOffset = 0;

  short[] backgroundUShort = new short[dstBands];
  for (int i = 0; i < dstBands; i++)
      backgroundUShort[i] = (short)backgroundValues[i];

        for (int h = 0; h < dstHeight; h++) {
            int pixelOffset = lineOffset;
            lineOffset += lineStride;

            warp.warpRect(dst.getX(), dst.getY()+h, dstWidth, 1,
                          warpData);
            int count = 0;
            for (int w = 0; w < dstWidth; w++) {
                /*
                 * The warp object subtract 0.5 from backward mapped
                 * source coordinate. Need to do a round to get the
                 * nearest neighbor. This is different from the standard
                 * nearest implementation.
                 */
                int sx = round(warpData[count++]);
                int sy = round(warpData[count++]);

                if (sx < minX || sx >= maxX || sy < minY || sy >= maxY) {
                    /* Fill with a background color. */
                    if (setBackground) {
                        for (int b = 0; b < dstBands; b++) {
                            data[b][pixelOffset+bandOffsets[b]] =
                                backgroundUShort[b];
                        }
                    }
                } else {
                    for (int b = 0; b < dstBands; b++) {
                        data[b][pixelOffset+bandOffsets[b]] =
                            (short)(iter.getSample(sx, sy, b) & 0xFFFF);
                    }
                }

                pixelOffset += pixelStride;
            }
View Full Code Here

Examples of javax.media.jai.iterator.RandomIter

            }
        }
    }

    private void computeRectShort(PlanarImage src, RasterAccessor dst) {
        RandomIter iter = RandomIterFactory.create(src, src.getBounds());

        int minX = src.getMinX();
        int maxX = src.getMaxX();
        int minY = src.getMinY();
        int maxY = src.getMaxY();

        int dstWidth = dst.getWidth();
        int dstHeight = dst.getHeight();
        int dstBands = dst.getNumBands();

        int lineStride = dst.getScanlineStride();
        int pixelStride = dst.getPixelStride();
        int[] bandOffsets = dst.getBandOffsets();
        short[][] data = dst.getShortDataArrays();

        float[] warpData = new float[2 * dstWidth];

        int lineOffset = 0;

        short[] backgroundShort = new short[dstBands];
  for (int i = 0; i < dstBands; i++)
      backgroundShort[i] = (short)backgroundValues[i];

        for (int h = 0; h < dstHeight; h++) {
            int pixelOffset = lineOffset;
            lineOffset += lineStride;

            warp.warpRect(dst.getX(), dst.getY()+h, dstWidth, 1,
                          warpData);
            int count = 0;
            for (int w = 0; w < dstWidth; w++) {
                /*
                 * The warp object subtract 0.5 from backward mapped
                 * source coordinate. Need to do a round to get the
                 * nearest neighbor. This is different from the standard
                 * nearest implementation.
                 */
                int sx = round(warpData[count++]);
                int sy = round(warpData[count++]);

                if (sx < minX || sx >= maxX || sy < minY || sy >= maxY) {
                    /* Fill with a background color. */
                    if (setBackground) {
                        for (int b = 0; b < dstBands; b++) {
                            data[b][pixelOffset+bandOffsets[b]] =
                                backgroundShort[b];
                        }
                    }
                } else {
                    for (int b = 0; b < dstBands; b++) {
                        data[b][pixelOffset+bandOffsets[b]] =
                            (short)iter.getSample(sx, sy, b);
                    }
                }

                pixelOffset += pixelStride;
            }
View Full Code Here

Examples of javax.media.jai.iterator.RandomIter

            }
        }
    }

    private void computeRectInt(PlanarImage src, RasterAccessor dst) {
        RandomIter iter = RandomIterFactory.create(src, src.getBounds());

        int minX = src.getMinX();
        int maxX = src.getMaxX();
        int minY = src.getMinY();
        int maxY = src.getMaxY();

        int dstWidth = dst.getWidth();
        int dstHeight = dst.getHeight();
        int dstBands = dst.getNumBands();

        int lineStride = dst.getScanlineStride();
        int pixelStride = dst.getPixelStride();
        int[] bandOffsets = dst.getBandOffsets();
        int[][] data = dst.getIntDataArrays();

        float[] warpData = new float[2 * dstWidth];

        int lineOffset = 0;

  int[] backgroundInt = new int[dstBands];
  for (int i = 0; i < dstBands; i++)
      backgroundInt[i] = (int)backgroundValues[i];

        for (int h = 0; h < dstHeight; h++) {
            int pixelOffset = lineOffset;
            lineOffset += lineStride;

            warp.warpRect(dst.getX(), dst.getY()+h, dstWidth, 1,
                          warpData);
            int count = 0;
            for (int w = 0; w < dstWidth; w++) {
                /*
                 * The warp object subtract 0.5 from backward mapped
                 * source coordinate. Need to do a round to get the
                 * nearest neighbor. This is different from the standard
                 * nearest implementation.
                 */
                int sx = round(warpData[count++]);
                int sy = round(warpData[count++]);

                if (sx < minX || sx >= maxX || sy < minY || sy >= maxY) {
                    /* Fill with a background color. */
                    if (setBackground) {
                        for (int b = 0; b < dstBands; b++) {
                            data[b][pixelOffset+bandOffsets[b]] =
                                backgroundInt[b];
                        }
                    }
                } else {
                    for (int b = 0; b < dstBands; b++) {
                        data[b][pixelOffset+bandOffsets[b]] =
                            iter.getSample(sx, sy, b);
                    }
                }

                pixelOffset += pixelStride;
            }
View Full Code Here

Examples of javax.media.jai.iterator.RandomIter

            }
        }
    }

    private void computeRectFloat(PlanarImage src, RasterAccessor dst) {
        RandomIter iter = RandomIterFactory.create(src, src.getBounds());

        int minX = src.getMinX();
        int maxX = src.getMaxX();
        int minY = src.getMinY();
        int maxY = src.getMaxY();

        int dstWidth = dst.getWidth();
        int dstHeight = dst.getHeight();
        int dstBands = dst.getNumBands();

        int lineStride = dst.getScanlineStride();
        int pixelStride = dst.getPixelStride();
        int[] bandOffsets = dst.getBandOffsets();
        float[][] data = dst.getFloatDataArrays();

        float[] warpData = new float[2 * dstWidth];

        int lineOffset = 0;

  float[] backgroundFloat = new float[dstBands];
  for (int i = 0; i < dstBands; i++)
      backgroundFloat[i] = (float)backgroundValues[i];

        for (int h = 0; h < dstHeight; h++) {
            int pixelOffset = lineOffset;
            lineOffset += lineStride;

            warp.warpRect(dst.getX(), dst.getY()+h, dstWidth, 1,
                          warpData);
            int count = 0;
            for (int w = 0; w < dstWidth; w++) {
                /*
                 * The warp object subtract 0.5 from backward mapped
                 * source coordinate. Need to do a round to get the
                 * nearest neighbor. This is different from the standard
                 * nearest implementation.
                 */
                int sx = round(warpData[count++]);
                int sy = round(warpData[count++]);

                if (sx < minX || sx >= maxX || sy < minY || sy >= maxY) {
                    /* Fill with a background color. */
                    if (setBackground) {
                        for (int b = 0; b < dstBands; b++) {
                            data[b][pixelOffset+bandOffsets[b]] =
                                backgroundFloat[b];
                        }
                    }
                } else {
                    for (int b = 0; b < dstBands; b++) {
                        data[b][pixelOffset+bandOffsets[b]] =
                            iter.getSampleFloat(sx, sy, b);
                    }
                }

                pixelOffset += pixelStride;
            }
View Full Code Here

Examples of javax.media.jai.iterator.RandomIter

            }
        }
    }

    private void computeRectDouble(PlanarImage src, RasterAccessor dst) {
        RandomIter iter = RandomIterFactory.create(src, src.getBounds());

        int minX = src.getMinX();
        int maxX = src.getMaxX();
        int minY = src.getMinY();
        int maxY = src.getMaxY();

        int dstWidth = dst.getWidth();
        int dstHeight = dst.getHeight();
        int dstBands = dst.getNumBands();

        int lineStride = dst.getScanlineStride();
        int pixelStride = dst.getPixelStride();
        int[] bandOffsets = dst.getBandOffsets();
        double[][] data = dst.getDoubleDataArrays();

        float[] warpData = new float[2 * dstWidth];

        int lineOffset = 0;

        for (int h = 0; h < dstHeight; h++) {
            int pixelOffset = lineOffset;
            lineOffset += lineStride;

            warp.warpRect(dst.getX(), dst.getY()+h, dstWidth, 1,
                          warpData);
            int count = 0;
            for (int w = 0; w < dstWidth; w++) {
                /*
                 * The warp object subtract 0.5 from backward mapped
                 * source coordinate. Need to do a round to get the
                 * nearest neighbor. This is different from the standard
                 * nearest implementation.
                 */
                int sx = round(warpData[count++]);
                int sy = round(warpData[count++]);

                if (sx < minX || sx >= maxX || sy < minY || sy >= maxY) {
                    /* Fill with a background color. */
                    if (setBackground) {
                        for (int b = 0; b < dstBands; b++) {
                            data[b][pixelOffset+bandOffsets[b]] =
                                backgroundValues[b];
                        }
                    }
                } else {
                    for (int b = 0; b < dstBands; b++) {
                        data[b][pixelOffset+bandOffsets[b]] =
                            iter.getSampleDouble(sx, sy, b);
                    }
                }

                pixelOffset += pixelStride;
            }
View Full Code Here

Examples of javax.media.jai.iterator.RandomIter

     * average as an instance of Color. The point coordinates are proportional to
     * the image.
     */
    private Color averageAround(BufferedImage i, double px, double py) {
        // Get an iterator for the image.
        RandomIter iterator = RandomIterFactory.create(i, null);
        // Get memory for a pixel and for the accumulator.
        double[] pixel = new double[i.getSampleModel().getNumBands()];
        double[] accum = new double[3];
        int numPixels = 0;
        // Sample the pixels.

        for (double x = px * i.getWidth() - sampleSize; x < px * i.getWidth() + sampleSize; x++) {
            for (double y = py * i.getHeight() - sampleSize; y < py * i.getHeight() + sampleSize; y++) {
                iterator.getPixel((int) x, (int) y, pixel);
                accum[0] += pixel[0];
                accum[1] += pixel[1];
                accum[2] += pixel[2];
                numPixels++;
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.