Class WritablePixelIterator

  • All Implemented Interfaces:
    Closeable, Auto­Closeable

    public abstract class WritablePixelIterator
    extends PixelIterator
    implements Closeable
    A pixel iterator capable to write sample values. This iterator can edit pixel values in place, or write values in a different destination image than the source image. Source and destination images must use the same sample model and the same coordinates (both for pixels and tiles).

    Contrarily to Pixel­Iterator, Writable­Pixel­Iterator needs to be closed after iteration in order to release tiles. Example:

    try (WritablePixelIterator it = WritablePixelIterator.create(image)) {
        double[] samples = null;
        while ( {
            samples = it.getPixel(samples);      // Get values in all bands.
            // Perform computation here...
            it.setPixels(sample);                // Replace values in all bands.
    Casting a Pixel­Iterator
    To check if a Pixel­Iterator can be used for writing pixels, a … instanceof Writable­Pixel­Iterator check is not sufficient. The Pixel­Iterator​.is­Writable() method should be invoked instead.

    Defined in the sis-feature module