|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jaitools.imageutils.iterator.WindowIterator
public class WindowIterator
An image iterator that passes a moving window over an image.
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 Summary | |
|---|---|
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. |
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
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 window
IllegalArgumentException - if any arguments other than bounds are null;
or if keyElement does not lie within windowDim
public 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 image
IllegalArgumentException - if any arguments other than bounds are null;
or if keyElement does not lie within windowDim
public 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 image
IllegalArgumentException - if any arguments other than bounds are null;
or if keyElement does not lie within windowDim;
or if either step distance is less than 1| Method Detail |
|---|
public 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 null
public 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 data
public 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 null
public 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 data
public 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 null
public 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 data
public 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 null
public 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 data
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||