As a complement to @Joop's answer:
All ImageIO ImageReader
implementations support an ImageReadParam
with source region specified (ImageReadParam.setSourceRegion(rect)
), so that you can extract only a specific region of the entire image. This will work for any reader, even if the underlying format doesn't support tiling, and also regardless of the tile size for a tiled TIFF (or other format supporting tiles).
Example:
ImageReader reader = ImageIO.getImageReaders(input).next();
reader.setInput(input);
ImageReadParam param = reader.getDefaultReadParam();
param.setSourceRegion(new Rectangle(x, y, w, h));
BufferedImage aoi = reader.read(0, param);
That said, reading the image tile by tile is probably the most efficient way to achieve what you asked for, using the TIFF format. :-)