Question about NDPI

Christoph Gohlke cgohlke at cgohlke.com
Sat May 11 16:20:48 EDT 2024



On 5/11/2024 12:15 PM, Martin Weihrauch wrote:
> Dear community,
> 
> my C-knowledge does not suffice to read the entire code of openslide-vendor-hamamatsu.c, but I am interested to better understand the Hamamatsu format.
> 
> If I see it correctly, it (ab)uses the Tiff format and stores a single JPEG in each zoom level, (ab)using the JPEG rules, e. g. by exceeding the 65,000 pixel limit, etc.
> 
> My question: how is it possible to quickly extract a tile from the large JPEG? Does it internally have multiple frames (the stripes) and if yes, how is it possible to locate the internal MCU/8x8 blocks without reading the entire stripe or does each stripe have to be "parsed" at least once completely? Is there something like a directory involved?
> 

Yes, the TIFF tags 65426 and 65432 (if >4 GB) should contain the lower 
and higher bytes of the offsets to the MCU blocks relative to the strip 
offset in tag #273 (StripOffsets). The JPEG header at StripOffsets[0] 
with length McuOffsets[0] can be prepended to a MCU block to decode just 
the image in the block.

Here's some Python code to get the MCU offsets: 
<https://github.com/cgohlke/tifffile/blob/9000e7463df6f0a7dfdc72c701796967fbffd4df/tifffile/tifffile.py#L8489-L8500>

Hope this helps,

Christoph


More information about the openslide-users mailing list