public class WindowIterator extends Object
Example of use:
RenderedImage myImage = ...
// Pass a 3x3 window, with the key element at pos (1,1), over band 0
// of the image
WindowIter iter = new WindowIter(myImage(myImage, null, new Dimension(3,3), new Point(1,1));
int[][] dataWindow = new int[3][3];
do {
iter.getWindow(dataWindow);
// do something with data
} while (iter.next());
As with the JAI RectIter.getSample methods, alternative getWindow methods
are provided to return values as either integers, floats or doubles, optionally for a
specified image band.
Note that control of the iterator position is different to the RectIter class which
has separate methods to advance and reset pixel, line and band position:
next() method which handles movement in both
X and Y directions.
xstep
and ystep arguments to the full constructor. If the step distance is larger than
the corresponding window dimension then some target image pixels will be absent from
the data windows returned by the iterator.
next method speculatively, although the
hasNext() method is also provided for convenience.
getPos() method.
outsideValue argument to the full
constructor.| Constructor and Description |
|---|
WindowIterator(RenderedImage image,
Rectangle bounds,
Dimension windowDim,
Point keyElement)
Creates a new iterator.
|
WindowIterator(RenderedImage image,
Rectangle bounds,
Dimension windowDim,
Point keyElement,
int xstep,
int ystep,
Number outsideValue)
Creates a new iterator.
|
WindowIterator(RenderedImage image,
Rectangle bounds,
Dimension windowDim,
Point keyElement,
Number outsideValue)
Creates a new iterator.
|
| Modifier and Type | Method and Description |
|---|---|
Point |
getPos()
Gets the target image coordinates of the pixel currently at the
window key element position.
|
Number[][] |
getWindow(Number[][] dest)
Gets the data window at the current iterator position in image band 0 as Number values.
|
Number[][] |
getWindow(Number[][] dest,
int band)
Gets the data window at the current iterator position and specified image band
as Number values.
|
double[][] |
getWindowDouble(double[][] dest)
Gets the data window at the current iterator position in image band 0 as double values.
|
double[][] |
getWindowDouble(double[][] dest,
int band)
Gets the data window at the current iterator position and specified image band
as double values.
|
float[][] |
getWindowFloat(float[][] dest)
Gets the data window at the current iterator position in image band 0 as float values.
|
float[][] |
getWindowFloat(float[][] dest,
int band)
Gets the data window at the current iterator position and specified image band
as float values.
|
int[][] |
getWindowInt(int[][] dest)
Gets the data window at the current iterator position in image band 0 as integer values.
|
int[][] |
getWindowInt(int[][] dest,
int band)
Gets the data window at the current iterator position and specified image band
as integer values.
|
boolean |
hasNext()
Tests if this iterator has more data.
|
boolean |
next()
Advances the iterator using the specified X and Y step distances.
|
public WindowIterator(RenderedImage image, Rectangle bounds, Dimension windowDim, Point keyElement)
image - the target imagebounds - the bounds for this iterator or null for the whole imagewindowDim - the dimensions of the data windowkeyElement - the position of the key element in the data windowIllegalArgumentException - if any arguments other than bounds are null;
or if keyElement does not lie within windowDimpublic WindowIterator(RenderedImage image, Rectangle bounds, Dimension windowDim, Point keyElement, Number outsideValue)
image - the target imagebounds - the bounds for this iterator or null for the whole imagewindowDim - the dimensions of the data windowkeyElement - the position of the key element in the data windowoutsideValue - value to return for any parts of the data window that are
beyond the bounds of the imageIllegalArgumentException - if any arguments other than bounds are null;
or if keyElement does not lie within windowDimpublic WindowIterator(RenderedImage image, Rectangle bounds, Dimension windowDim, Point keyElement, int xstep, int ystep, Number outsideValue)
image - the target imagebounds - the bounds for this iterator or null for the whole imagewindowDim - the dimensions of the data windowkeyElement - the position of the key element in the data windowxstep - step distance in X-direction (pixels)ystep - step distance in Y-direction (lines)outsideValue - value to return for any parts of the data window that are
beyond the bounds of the imageIllegalArgumentException - if any arguments other than bounds are null;
or if keyElement does not lie within windowDim;
or if either step distance is less than 1public Point getPos()
null.public boolean hasNext()
true if more data are available; false otherwisepublic boolean next()
false.true if the iterator was advanced; false if it was
already finishedpublic Number[][] getWindow(Number[][] dest)
dest is null or not equal in size to the data window
dimensions a new array will be allocated, otherwise the provided array
is filled. In either case, the destination array is returned for convenience.dest - destination array or nullpublic Number[][] getWindow(Number[][] dest, int band)
dest is null or not equal in size to the data window
dimensions a new array will be allocated, otherwise the provided array
is filled. In either case, the destination array is returned for convenience.dest - destination array or nullband - the image band from which to retrieve datapublic int[][] getWindowInt(int[][] dest)
dest is null or not equal in size to the data window
dimensions a new array will be allocated, otherwise the provided array
is filled. In either case, the destination array is returned for convenience.dest - destination array or nullpublic int[][] getWindowInt(int[][] dest,
int band)
dest is null or not equal in size to the data window
dimensions a new array will be allocated, otherwise the provided array
is filled. In either case, the destination array is returned for convenience.dest - destination array or nullband - the image band from which to retrieve datapublic float[][] getWindowFloat(float[][] dest)
dest is null or not equal in size to the data window
dimensions a new array will be allocated, otherwise the provided array
is filled. In either case, the destination array is returned for convenience.dest - destination array or nullpublic float[][] getWindowFloat(float[][] dest,
int band)
dest is null or not equal in size to the data window
dimensions a new array will be allocated, otherwise the provided array
is filled. In either case, the destination array is returned for convenience.dest - destination array or nullband - the image band from which to retrieve datapublic double[][] getWindowDouble(double[][] dest)
dest is null or not equal in size to the data window
dimensions a new array will be allocated, otherwise the provided array
is filled. In either case, the destination array is returned for convenience.dest - destination array or nullpublic double[][] getWindowDouble(double[][] dest,
int band)
dest is null or not equal in size to the data window
dimensions a new array will be allocated, otherwise the provided array
is filled. In either case, the destination array is returned for convenience.dest - destination array or nullband - the image band from which to retrieve dataCopyright © 2009–2018. All rights reserved.