Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Fix trailing zero bit mask. #2

Merged
merged 1 commit into from
Oct 30, 2024
Merged

Conversation

bostelk
Copy link

@bostelk bostelk commented Oct 29, 2024

The trailing zero bit mask (0b11110111) was zeroing the incorrect bits: bit 3 instead of bits 0 - 2 or up to the number of trailing zero bits. The default bit mask (0b11111000) should now be correct.

The result is better compression on disk. A 20 tiff Zarr volume was compressed from 702 MB to 466 MB or 66% of its original size. The apparent image quality is similar, at least to my eyes.

This work is intended to address this issue: ScrollPrize/vesuvius#4

Before and After Comparison

Figure_1

The trailing zero bit mask (0b11110111) was zeroing the incorrect bits: bit 3 instead of bits 0 - 2 or up to the number of trailing zero bits. The bit mask (0b11111000) should now be correct.
@bostelk
Copy link
Author

bostelk commented Oct 29, 2024

FWIW I had to make two edits to run the script:

  1. Comment out a debug line (https://github.com/schillij95/scroll2zarr/blob/main/scroll_to_ome.py#L385) and
  2. Offset the tiff index to: inttiffs[minz + i] on this line (https://github.com/schillij95/scroll2zarr/blob/main/scroll_to_ome.py#L327).

@schillij95
Copy link
Owner

Thank you bostelk for getting this bug found and fixed!

@schillij95 schillij95 merged commit c89a1af into schillij95:main Oct 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants