Repository navigation
Fix TY1 compression of unsigned integer images - #681
Merged
Merged
Conversation
compTY1 computed pixel differences in the input dtype, so any decrease between neighbouring uint8/uint16/uint32 pixels wrapped around and was stored as a large positive step. Compute the differences in int64.
kif
approved these changes
Oct 27, 2026
kif
left a comment
Member
There was a problem hiding this comment.
Good catch. Thanks for the contribution.
LGTM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
compTY1computes the pixel differences withnumpy.zeros_like(fdata), so they take the input dtype. With uint8, uint16 or uint32 data, any decrease from one pixel to the next wraps around and is stored as a large positive step. Every pixel after it is then off by 256, 65536, and so on. Unsigned input is common here: uint16 TIFF data, uint32 Eiger frames, and uint8 masks (the existingface.mskto OXD conversion test hits this path but only checks that the file exists).Observed on 2026.6.0 and main:
[[ 0 37 74 265 302]]. Expected:[[ 0 37 74 9 46]].int16 data with a full-range step (-32768 to 32767) also wraps for the same reason. The fix converts the input to int64 before computing the differences. The decoder already works in int64, so nothing changes on read.