[geotk] Efficient subsetting/subsampling of large image

Jon Blower j.d.blower at reading.ac.uk
Mon Sep 28 11:50:03 EDT 2009


Hi Martin,

Thanks very much!  I had never used ImageReadParam before.  Apologies
that this wasn't really a geotoolkit question...

Out of interest, do you know how much difference it makes if the image
is compressed (e.g. JPEGs versus BMPs)?  I would imagine that the
decompression step could have a significant effect on performance.

Cheers, Jon

On Mon, Sep 28, 2009 at 4:33 PM, Martin Desruisseaux
<martin.desruisseaux at geomatys.fr> wrote:
> Hello Jon
>
> Jon Blower a écrit :
>>
>> Is it possible to use Geotoolkit to read a subset of pixels from a
>> large image without reading the entire image into memory?  Such
>> behaviour would be very useful for a Web Map Service implementation.
>
> If you are reading a single image, you can do that using the standard Java
> API defined in the javax.imageio package. The example below read 1 pixel,
> skip 2, read 1 pixel, etc.
>
>   ImageReader reader = ImageIO.getImageReaders(input).next();
>   reader.setInput(input);
>   ImageReadParam param = reader.getDefaultReadParam();
>   param.setSourceSubsampling(3, 3, 0, 0);
>   RenderedImage image = reader.read(0, image);
>
> Note that you can also set a subarea of the region you want to read, or read
> only some bands using other setter methods in ImageReadParam.
>
> If you want to do the same but on a mosaic of images instead than a single
> image, you can do that using the org.geotoolkit.image.io.mosaic package. The
> steps are:
>
> 1) Create one Tile object for each image.
> 2) Instantiate a new MosaicImageReader object.
> 3) Invoke reader.setInput(input) where the input is the array of
>   tiles created at step 1.
> 4) Use the standard Java API exactly as you would do for the single
>   image case. MosaicImageReader will take care of reading only the
>   needed images.
>
>    Martin
>



-- 
Dr Jon Blower
Technical Director, Reading e-Science Centre
Environmental Systems Science Centre
University of Reading
Harry Pitt Building, 3 Earley Gate
Reading RG6 6AL. UK
Tel: +44 (0)118 378 5213
Fax: +44 (0)118 378 6413
j.d.blower at reading.ac.uk
http://www.nerc-essc.ac.uk/People/Staff/Blower_J.htm


More information about the Geotoolkit mailing list