org.geotoolkit.image
Class TransfertRectIter

Object
  extended by TransfertRectIter
All Implemented Interfaces:
RectIter, WritableRectIter

public class TransfertRectIter
extends Object
implements WritableRectIter

A writable iterator that read pixel values from an image, and write pixel values to a different image. Every get methods read values from the source image specified at creation time. Every set methods write values to the destination image specified at creation time, which may or may not be the same than the source image. This is different than the usual WritableRectIter contract, which read and write values in the same image.

The create(...) methods return an instance of TransfertRectIter only if the source and target rasters are different. Callers can use this contract for optimizing their code. For example implementations of PointOpImage that copy some pixel values from source to target rasters can skip the copy phase if the iterator is not an instance of TransfertRectIter.

Since:
2.3
Version:
3.11
Author:
Martin Desruisseaux (IRD, Geomatys)
Module:
coverage/geotk-coverage (download)    View source code for this class

Field Summary
protected  WritableRectIter dst
          The iterator to use for writing to the destination destination.
protected  RectIter src
          The iterator to use for reading from the source.
 
Constructor Summary
protected TransfertRectIter(RectIter src, WritableRectIter dst)
          Constructs a TransfertRectIter object.
 
Method Summary
static WritableRectIter create(Raster src, WritableRaster dst, Rectangle bounds)
          Creates a WritableRectIter for the specified source and destination rasters.
static WritableRectIter create(RectIter src, WritableRectIter dst)
          Creates a WritableRectIter for the specified source and destination iterator.
static WritableRectIter create(RenderedImage src, WritableRaster dst, Rectangle bounds)
          Creates a WritableRectIter for the specified source image and destination raster.
static WritableRectIter create(RenderedImage src, WritableRenderedImage dst, Rectangle bounds)
          Creates a WritableRectIter for the specified source and destination images.
 boolean finishedBands()
          Returns true if the max band in the image has been exceeded.
 boolean finishedLines()
          Returns true if the bottom row of the bounding rectangle has been passed.
 boolean finishedPixels()
          Returns true if the right edge of the bounding rectangle has been passed.
 double[] getPixel(double[] array)
          Returns the samples of the current pixel from the image in an array of double.
 float[] getPixel(float[] array)
          Returns the samples of the current pixel from the image in an array of float.
 int[] getPixel(int[] array)
          Returns the samples of the current pixel from the image in an array of int.
 int getSample()
          Returns the current sample as an integer.
 int getSample(int b)
          Returns the specified sample of the current pixel as an integer.
 double getSampleDouble()
          Returns the current sample as a double.
 double getSampleDouble(int b)
          Returns the specified sample of the current pixel as a double.
 float getSampleFloat()
          Returns the current sample as a float.
 float getSampleFloat(int b)
          Returns the specified sample of the current pixel as a float.
 void jumpLines(int num)
          Jumps downward num lines from the current position.
 void jumpPixels(int num)
          Jumps rightward num pixels from the current position.
 void nextBand()
          Sets the iterator to the next band in the image.
 boolean nextBandDone()
          Sets the iterator to the next band in the image, and returns true if the max band has been exceeded.
 void nextLine()
          Sets the iterator to the next line of the image.
 boolean nextLineDone()
          Sets the iterator to the next line in the image, and returns true if the bottom row of the bounding rectangle has been passed.
 void nextPixel()
          Sets the iterator to the next pixel in image (that is, move rightward).
 boolean nextPixelDone()
          Sets the iterator to the next pixel in the image (that is, move rightward).
 void setPixel(double[] array)
          Sets all samples of the current pixel to a set of double values.
 void setPixel(float[] array)
          Sets all samples of the current pixel to a set of float values.
 void setPixel(int[] array)
          Sets all samples of the current pixel to a set of int values.
 void setSample(double s)
          Sets the current sample to a double value.
 void setSample(float s)
          Sets the current sample to a float value.
 void setSample(int s)
          Sets the current sample to an integral value.
 void setSample(int b, double s)
          Sets the specified sample of the current pixel to a double value.
 void setSample(int b, float s)
          Sets the specified sample of the current pixel to a float value.
 void setSample(int b, int s)
          Sets the specified sample of the current pixel to an integral value.
 void startBands()
          Sets the iterator to the first band of the image.
 void startLines()
          Sets the iterator to the first line of its bounding rectangle.
 void startPixels()
          Sets the iterator to the leftmost pixel of its bounding rectangle.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

src

protected final RectIter src
The iterator to use for reading from the source.

Since:
3.11

dst

protected final WritableRectIter dst
The iterator to use for writing to the destination destination.

Since:
3.11
Constructor Detail

TransfertRectIter

protected TransfertRectIter(RectIter src,
                            WritableRectIter dst)
Constructs a TransfertRectIter object.

Parameters:
src - The iterator to use for reading from the source.
dst - The iterator to use for writing to the destination destination.
Since:
3.11
Method Detail

create

public static WritableRectIter create(RectIter src,
                                      WritableRectIter dst)
Creates a WritableRectIter for the specified source and destination iterator. The two iterators must iterate over a rectangle of the same size, otherwise a RasterFormatException will be thrown during the iteration.

Parameters:
src - The source iterator.
dst - The destination iterator.
Returns:
An iterator that read samples from src and write samples to dst. If src == dst, then the destination iterator itself is returned.

create

public static WritableRectIter create(RenderedImage src,
                                      WritableRenderedImage dst,
                                      Rectangle bounds)
Creates a WritableRectIter for the specified source and destination images. The given rectangle must be in the bounds of both images (this will not be verified).

Parameters:
src - The source image.
dst - The destination image.
bounds - The region of the images to iterate over.
Returns:
An iterator that read samples from src and write samples to dst. It will be an instance of TransfertRectIter if and only if the source and destination images are not the same.
Since:
3.00

create

public static WritableRectIter create(RenderedImage src,
                                      WritableRaster dst,
                                      Rectangle bounds)
Creates a WritableRectIter for the specified source image and destination raster. The given rectangle must be in the bounds of both arguments (this will not be verified).

Parameters:
src - The source image.
dst - The destination raster.
bounds - The region of the image or raster to iterate over.
Returns:
An iterator that read samples from src and write samples to dst. It will be an instance of TransfertRectIter if and only if the source and destination rasters are not the same.
Since:
3.00

create

public static WritableRectIter create(Raster src,
                                      WritableRaster dst,
                                      Rectangle bounds)
Creates a WritableRectIter for the specified source and destination rasters. The given rectangle must be in the bounds of both rasters (this will not be verified).

Parameters:
src - The source raster.
dst - The destination raster.
bounds - The region of the rasters to iterate over.
Returns:
An iterator that read sample from src and write sample to dst. It will be an instance of TransfertRectIter if and only if the source and destination rasters are not the same.
Since:
3.00

startLines

public void startLines()
Sets the iterator to the first line of its bounding rectangle.

Specified by:
startLines in interface RectIter

startPixels

public void startPixels()
Sets the iterator to the leftmost pixel of its bounding rectangle.

Specified by:
startPixels in interface RectIter

startBands

public void startBands()
Sets the iterator to the first band of the image.

Specified by:
startBands in interface RectIter

jumpLines

public void jumpLines(int num)
Jumps downward num lines from the current position.

Specified by:
jumpLines in interface RectIter
Parameters:
num - The number of lines to jump.

jumpPixels

public void jumpPixels(int num)
Jumps rightward num pixels from the current position.

Specified by:
jumpPixels in interface RectIter
Parameters:
num - The number of pixels to jump.

nextLine

public void nextLine()
Sets the iterator to the next line of the image.

Specified by:
nextLine in interface RectIter

nextPixel

public void nextPixel()
Sets the iterator to the next pixel in image (that is, move rightward).

Specified by:
nextPixel in interface RectIter

nextBand

public void nextBand()
Sets the iterator to the next band in the image.

Specified by:
nextBand in interface RectIter

nextLineDone

public boolean nextLineDone()
Sets the iterator to the next line in the image, and returns true if the bottom row of the bounding rectangle has been passed.

Specified by:
nextLineDone in interface RectIter
Returns:
true if the iteration over lines is finished.

nextPixelDone

public boolean nextPixelDone()
Sets the iterator to the next pixel in the image (that is, move rightward).

Specified by:
nextPixelDone in interface RectIter
Returns:
true if the iteration over pixels is finished.

nextBandDone

public boolean nextBandDone()
Sets the iterator to the next band in the image, and returns true if the max band has been exceeded.

Specified by:
nextBandDone in interface RectIter
Returns:
true if the iteration over bands is finished.

finishedLines

public boolean finishedLines()
Returns true if the bottom row of the bounding rectangle has been passed.

Specified by:
finishedLines in interface RectIter
Returns:
true if the iteration over lines is finished.

finishedPixels

public boolean finishedPixels()
Returns true if the right edge of the bounding rectangle has been passed.

Specified by:
finishedPixels in interface RectIter
Returns:
true if the iteration over pixels is finished.

finishedBands

public boolean finishedBands()
Returns true if the max band in the image has been exceeded.

Specified by:
finishedBands in interface RectIter
Returns:
true if the iteration over bands is finished.

getPixel

public int[] getPixel(int[] array)
Returns the samples of the current pixel from the image in an array of int.

Specified by:
getPixel in interface RectIter
Parameters:
array - The array where to store the sample values.
Returns:
The array of sample values.

getPixel

public float[] getPixel(float[] array)
Returns the samples of the current pixel from the image in an array of float.

Specified by:
getPixel in interface RectIter
Parameters:
array - The array where to store the sample values.
Returns:
The array of sample values.

getPixel

public double[] getPixel(double[] array)
Returns the samples of the current pixel from the image in an array of double.

Specified by:
getPixel in interface RectIter
Parameters:
array - The array where to store the sample values.
Returns:
The array of sample values.

getSample

public int getSample()
Returns the current sample as an integer.

Specified by:
getSample in interface RectIter
Returns:
The current sample value.

getSample

public int getSample(int b)
Returns the specified sample of the current pixel as an integer.

Specified by:
getSample in interface RectIter
Parameters:
b - The band for which to get the sample value.
Returns:
The sample value at the given band.

getSampleFloat

public float getSampleFloat()
Returns the current sample as a float.

Specified by:
getSampleFloat in interface RectIter
Returns:
The current sample value.

getSampleFloat

public float getSampleFloat(int b)
Returns the specified sample of the current pixel as a float.

Specified by:
getSampleFloat in interface RectIter
Parameters:
b - The band for which to get the sample value.
Returns:
The sample value at the given band.

getSampleDouble

public double getSampleDouble()
Returns the current sample as a double.

Specified by:
getSampleDouble in interface RectIter
Returns:
The current sample value.

getSampleDouble

public double getSampleDouble(int b)
Returns the specified sample of the current pixel as a double.

Specified by:
getSampleDouble in interface RectIter
Parameters:
b - The band for which to get the sample value.
Returns:
The sample value at the given band.

setPixel

public void setPixel(int[] array)
Sets all samples of the current pixel to a set of int values.

Specified by:
setPixel in interface WritableRectIter
Parameters:
array - The new pixel values.

setPixel

public void setPixel(float[] array)
Sets all samples of the current pixel to a set of float values.

Specified by:
setPixel in interface WritableRectIter
Parameters:
array - The new pixel values.

setPixel

public void setPixel(double[] array)
Sets all samples of the current pixel to a set of double values.

Specified by:
setPixel in interface WritableRectIter
Parameters:
array - The new pixel values.

setSample

public void setSample(int s)
Sets the current sample to an integral value.

Specified by:
setSample in interface WritableRectIter
Parameters:
s - The new sample value.

setSample

public void setSample(float s)
Sets the current sample to a float value.

Specified by:
setSample in interface WritableRectIter
Parameters:
s - The new sample value.

setSample

public void setSample(double s)
Sets the current sample to a double value.

Specified by:
setSample in interface WritableRectIter
Parameters:
s - The new sample value.

setSample

public void setSample(int b,
                      int s)
Sets the specified sample of the current pixel to an integral value.

Specified by:
setSample in interface WritableRectIter
Parameters:
b - The band for which to set the sample value.
s - The new sample value.

setSample

public void setSample(int b,
                      float s)
Sets the specified sample of the current pixel to a float value.

Specified by:
setSample in interface WritableRectIter
Parameters:
b - The band for which to set the sample value.
s - The new sample value.

setSample

public void setSample(int b,
                      double s)
Sets the specified sample of the current pixel to a double value.

Specified by:
setSample in interface WritableRectIter
Parameters:
b - The band for which to set the sample value.
s - The new sample value.


Copyright © 2009-2012 Geotoolkit.org. All Rights Reserved.