Skip to content

fix(orientation): allocate matrix transform output with the input typed array type - #602

Merged
wayfarer3130 merged 2 commits into
dcmjs-org:masterfrom
entity-0-0-2:fix/typed-matrix-transforms
Nov 24, 2026
Merged

wayfarer3130 merged 2 commits into
dcmjs-org:masterfrom
entity-0-0-2:fix/typed-matrix-transforms

Conversation

@entity-0-0-2

@entity-0-0-2 entity-0-0-2 commented Oct 9, 2026 •

Copy link
Copy Markdown

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.

@netlify

netlify Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for dcmjs2 ready!

Name Link
🔨 Latest commit ba32379
🔍 Latest deploy log https://app.netlify.com/projects/dcmjs2/deploys/6ac9751364056c0008f6f32a
😎 Deploy Preview https://deploy-preview-602--dcmjs2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for dcmjs2 ready!

Name Link
🔨 Latest commit 446a406
🔍 Latest deploy log https://app.netlify.com/projects/dcmjs2/deploys/6b05f50ec2e279d5b9930b27
😎 Deploy Preview https://deploy-preview-602--dcmjs2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@wayfarer3130
wayfarer3130 merged commit 32167ab into dcmjs-org:master Nov 24, 2026
8 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 0.53.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants