Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for NDPI images >4GB #276

Closed
wants to merge 4 commits into from
Closed

Conversation

ntrahearn
Copy link

Addresses issue #174 (and possibly others), regarding the reading of large NDPI files. This issue stems from the fact that classical TIFF (and by extension, NDPI) images only support up to 32 bit values for tagged metadata. However, due to the nature of whole slide image data, it isn't uncommon for the size of an NDPI to exceed the 32 bit range. This means that key metadata, such as the byte positions of image layers or their size in bytes, may be too large to store in a traditional TIFF IFD entry.

Currently OpenSlide relies on heuristics to determine the high bits of 64 bit addresses, which fail in some cases. However, this is unnecessary, as NDPI actually stores the high bits of the offset/value of each tag in 4 byte blocks immediately after the end of the IFD.

This fix modifies openslide-decode-tifflike.c to append these extra 4 bytes to each IFD entry's value/offset and, if necessary, modifies its type to LONG8.

This fix also modifies openslide-vendor-hamamatsu.c to construct correct restart marker addresses. Currently only the values in TIFF tag 65426 are used, which are only the lower 32 bits of each address. High bits are stored in TIFF tag 65432, so these are now appended before mcu_starts are calculated

@andor-pierdelacabeza
Copy link

Interesting!

@AndyBlake
Copy link

hiya - tried this with a 30gb ndpi and cannot get it work - same issue arises:

openslide-write-png: ./largeslide.ndpi: Can't validate JPEG for directory 0: Expected marker at 21474841381, found none
for example.
this is after compiling from source from your master branch https://github.com/ntrahearn/openslide

@andor-pierdelacabeza
Copy link

That's a big file, @AndyBlake . What's the resolution for that? What device did you use for scanning? (Just out of curiosity)

@JiweiMaster
Copy link

@ntrahearn Hi, ntrahearn, Do you know how to use this PR on windows?, maybe you have windows version openslide of this PR. Look forward to your reply,thanks.

In some newer NDPI files it seems that the tiff tag containing the higher bits of the restart markers is sometimes omitted if it isn't needed. So this adds an additional check for the presence of just the lower bit tag.
@Signynt
Copy link

Signynt commented Jul 25, 2023

Works great on Ubuntu 22.04 LTS, makes working with files >4GB the same as smaller ones.

@bgilbert
Copy link
Member

@ntrahearn Thanks very much for tracking this down! Would you be willing to rebase your changes onto current Git main? There have been several internal API changes since you originally did this work.

Also, please certify to the Developer Certificate of Origin by adding signoffs to your commit messages. Even if you don't have time to rebase your changes onto main, if you can update your commit messages in-place to add signoffs, I can handle updating the PR and getting it landed.

@ntrahearn
Copy link
Author

Sure, I've made the changes and opened a fresh pull request here:

#602

@bgilbert
Copy link
Member

Thanks! Closing in favor of your updated PR #602.

@bgilbert bgilbert closed this May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants