Repository navigation
fix(orientation): allocate matrix transform output with the input typed array type - #602
Merged
wayfarer3130 merged 2 commits intoNov 24, 2026
Conversation
✅ Deploy Preview for dcmjs2 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
✅ Deploy Preview for dcmjs2 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
wayfarer3130
approved these changes
Nov 24, 2026
|
🎉 This PR is included in version 0.53.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This was referenced Nov 24, 2026
wayfarer3130
added a commit
that referenced
this pull request
Nov 25, 2026
…e (port of #602) (#661) flipMatrix2D.h, flipMatrix2D.v and rotateMatrix902D always allocated a Uint8Array, so 16-bit input lost its high byte ([300, 513] -> [44, 1]). Allocate the output with the constructor of the input data. Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
flipMatrix2D and rotateMatrix902D allocate their output as Uint8Array regardless of input type, so 16-bit pixel data loses values through any flip or rotation: [300, 513] comes back as [44, 1]. Reported as silent medical label corruption in cornerstonejs/cornerstone3D#2961.
Both utilities pass new Uint8Array(rows * cols) to ndarray, unchanged since their introduction in 2019 (3869431 and 73e0c33). dcmjs's own SEG adapters (Segmentation_3X.js:567, Segmentation_4X.js:1338) feed them 16-bit labelmaps.
The three allocation sites now use the input array's constructor so the output dtype matches the input. Tests for 16-bit horizontal flip, vertical flip, rotation and a Uint8Array passthrough fail on master and pass with the change, and the adapters regression suite passes.