0

How can I display the image (pixel data) of the different directories inside a single tiff file?

I have several tiff-based files (of format ndpi, svs, bif, etc these are digital pathology images) each of which contain a pyramidal-like structure of Image File Directories. When I run tiffinfo or tiffdump on these images I am informed of the different directories present. e.g.

when running tiffinfo my_file I get the following output

TIFF Directory at offset 0x898b0f0 (144224496)
  Subfile Type: (0 = 0x0)
  Image Width: 6473 Image Length: 6296 Image Depth: 1
  Tile Width: 240 Tile Length: 240
  Bits/Sample: 8
  Compression Scheme: 33005 (0x80ed)
  Photometric Interpretation: RGB color
  Samples/Pixel: 3
  Planar Configuration: single image plane
  ImageDescription: Aperio Image Library v12.0.15 
26416x25286 [0,100 25895x25186] (240x240) -> 6473x6296 J2K/KDU Q=70
TIFF Directory at offset 0x89d39e4 (144521700)
  Subfile Type: (0 = 0x0)
  Image Width: 1618 Image Length: 1574 Image Depth: 1
  Tile Width: 240 Tile Length: 240
  Bits/Sample: 8
  Compression Scheme: 33005 (0x80ed)
  Photometric Interpretation: RGB color
  Samples/Pixel: 3
  Planar Configuration: single image plane
  ImageDescription: Aperio Image Library v12.0.15 
26416x25286 [0,100 25895x25186] (240x240) -> 1618x1574 J2K/KDU Q=70
TIFF Directory at offset 0x8a87fc0 (145260480)
  Subfile Type: reduced-resolution image (1 = 0x1)
  Image Width: 739 Image Length: 704 Image Depth: 1
  Bits/Sample: 8
  Compression Scheme: LZW
  Photometric Interpretation: RGB color
  Samples/Pixel: 3
  Rows/Strip: 3
  Planar Configuration: single image plane
  ImageDescription: Aperio Image Library v12.0.15 
label 739x704
  Predictor: horizontal differencing 2 (0x2)

How can I now use a Python library to visually inspect the images of each TIFF directories?

gota
  • 2,338
  • 4
  • 25
  • 45
  • 1
    Try [openslide-python](https://pypi.org/project/openslide-python/), [slideio](https://pypi.org/project/slideio/), or [tifffile](https://pypi.org/project/tifffile/). Standard TIFF readers are not aware of the specific formats and compression schemes used in WSI. – cgohlke Jun 03 '22 at 15:30
  • @cgohlke, yes I have openslide, how do I access each directory? I tried read_region(location, level, size), but openslide only sees 1 level for my file, whereas I know for a fact that the file has 6 directories – gota Jun 03 '22 at 17:25
  • The output only shows three IFDs. Besides baseline and level images, SVS files may contain thumbnail, macro, and label images. Anyway, try [tifffile](https://github.com/cgohlke/tifffile/blob/375d97f62df6482142b51f1b38a49bdd24d18a60/tifffile/tifffile.py#L444-L448) to iterate over the IFDs/pages and read the images. – cgohlke Jun 03 '22 at 18:20

0 Answers0