1997.01.07 11:41 "Efficient load of a small part of an image?", by Filip Larsen

1997.01.07 11:41 "Efficient load of a small part of an image?", by Filip Larsen

Hi there, I'm new to this list.

I was wondering if there is a simple, yet efficient way of loading only a small rectangular part of a TIFF image using libtiff?

We (Kampsax Geoplan) have a set of 3750x2500 24-bit TIFF files, each covering a grid on a uniform recangular geographic grid. I'm now making a small program that given an arbitrary rectangle in "geographic" coordinates will locate the "grid" TIFF files needed, load the parts of those that are necessary and tile the whole thing together to one big image.

So, for efficiency I would like to avoid loading each 30 MB image (over NFS-mounted disks!) when I only need, say, 1 MB of it. However, as far as I can see, there is no direct support in libtiff for loading only parts of a general image. It seems to me that the "logical" behaviour of what I want can be accomplished by using a custom put-function in TIFFRGBAImageGet (one that almost simply ignores data outside the requested rectangle), but the underlying libtiff code will still "iterate" through the whole image in the process, thus reading 30 MB instead of only 1 MB.

Do I really have to write a complicated low-level reader to get what I want? And if so, are there any good examples I can work from? (I couldn't find any examples in the libtiff code tree that covers this; all code that needs to "understand" the image uses RGBAImage).

BTW, I use libtiff version 3.4beta35, compiled under Sun/Solaris/Linux.

Best regards,

-- 
--------------------------------------------------------------
Filip Larsen, M.Sc.(Eng.), Computer and Computational Science
mailto:filip@datashopper.dk  http://chaos.fys.dtu.dk/~filip
--------------------------------------------------------------