OME-TIFF n-pages versus bands swapped? #4009
-
Hi there, So I'm using the C++ bindings to read in OME-TIFF images. My understanding is the current OME-TIFF specification assigns the following dimensions: Should I assume that the default for libvips is to assign the volumetric (Z) dimension to Here's some output: Metadata printed using the C++ API:
Metadata printed using
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello @tomouellette, The libvips TIFF reader is a general one, with only a few additions to make working with OME-TIFF easier. Since it tries to give you exactly what's in the TIFF file, you need to know how OME-TIFF images are encoded. OME-TIFF images are all one band, and they use the pages dimension to store extra bands. Pyramids are stored in sub-ifd levels off each page. They do this because many microscopes have different cameras for different modalities, so you can't be sure different channels will have the same number of pixels in each direction. The When reading OME-TIFF with libvips the best strategy is to open page 0 and get the IMAGEDESCRIPTION XML. Parse that and figure out which channels (bands, pages, etc.) you want to load as a group. libvips needs all bands in an image to have the same pixel dimensions, so (for example) you may find you need to upscale some of the fluorescence bands before you can load them, or you might prefer to load them as a separate image. You can almost always load RGB as a set, fortunately. You can load a set of consecutive pages of the same size with eg. (using python for brevity): ome = pyvips.Image.new_from_file("xxx.ome.tiff", page=2, n=3) Then split that to a set of pages and join them bandwise. pages = ome.pagesplit()
image = pages[0].bandjoin(pages[1:]) Finally, tag the image as being RGB with: image = image.copy(interpretation="srgb") This works well for volumetric OME-TIFF too, though you should probably tag them as |
Beta Was this translation helpful? Give feedback.
Hello @tomouellette,
The libvips TIFF reader is a general one, with only a few additions to make working with OME-TIFF easier. Since it tries to give you exactly what's in the TIFF file, you need to know how OME-TIFF images are encoded.
OME-TIFF images are all one band, and they use the pages dimension to store extra bands. Pyramids are stored in sub-ifd levels off each page. They do this because many microscopes have different cameras for different modalities, so you can't be sure different channels will have the same number of pixels in each direction.
The
tiffinfo
utility is very handy for seeing the internal structure of a TIFF file.When reading OME-TIFF with libvips the best strateg…