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

fix(dicom-image-loader): add rgba condition interception for canvas createImageData API #1043

Merged
merged 2 commits into from
Jan 31, 2024

Conversation

Blackman99
Copy link
Contributor

@Blackman99 Blackman99 commented Jan 26, 2024

Context

The canvas context API createImageData would always return a ImageData . And its data field is always a rgba color mode Uint8ClampedArray , like this:
image

In the newest vtk package which has already been upragded in cornserstone repo would throw a error like this:
image

As a result, the image would not render.

This PR fix it.

Changes & Results

Add a condition, if not using rgba, then replace the data with a new Uint8ClampedArray with imageFrame.samplesPerPixel * columns * rows length

Testing

I've tested on my private project. I'm sorry I can't share it with others because the image
belongs to company.

Sorr for the inconvenience.

Checklist

PR

  • My Pull Request title is descriptive, accurate and follows the
    semantic-release format and guidelines.

Code

Public Documentation Updates

  • The documentation page has been updated as necessary for any public API
    additions or removals.

Tested Environment

  • OS: Ubuntu 23.10
  • Node version: 20.10.0
  • Browser: Chrome 120.0.6099.227

Copy link

netlify bot commented Jan 26, 2024

Deploy Preview for cornerstone-3d-docs ready!

Name Link
🔨 Latest commit 55187b2
🔍 Latest deploy log https://app.netlify.com/sites/cornerstone-3d-docs/deploys/65b707451f612e0008944e2b
😎 Deploy Preview https://deploy-preview-1043--cornerstone-3d-docs.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 site configuration.

@Sergey1888888
Copy link
Contributor

I have the same problem. Would be nice if it will be merged and fix in my project too. Because now I have to using hack with replacing pixelData and updating actors for viewports.

@sedghi
Copy link
Member

sedghi commented Jan 26, 2024

Can you describe the image that needs to be tested?

@vnosikov
Copy link

vnosikov commented Jan 26, 2024

I can't provide a sample image because it is a corporate policy not to provide them, but I confirm that there is a problem after vtk added that check and fixes like this (see also #1002) solve it

@Blackman99
Copy link
Contributor Author

Can you describe the image that needs to be tested?

A dicom file with rgb color series image would do

@baokeyu123
Copy link
Contributor

I think that this is root cause about PR1038. when i show the dicom image tag(0028,0004) is rgb, this problem will arise.
because context.createimagedata is based on rgba,its length doesn't divisible by 3.
due to vtk.js upgrade,It adds a conditional judgment about whether you can divide by 3.
Therefore, except for common multiples of 3 and 4, rgb DICOM cannot display images and will not give any prompts.

@baokeyu123
Copy link
Contributor

@Blackman99 Hey man,i suggest changing3 * imageFrame.columns * imageFrame.rows to imageFrame.samplesPerPixel* imageFrame.columns * imageFrame.rows.

@Blackman99
Copy link
Contributor Author

@Blackman99 Hey man,i suggest changing3 * imageFrame.columns * imageFrame.rows to imageFrame.samplesPerPixel* imageFrame.columns * imageFrame.rows.

Thanks! Change has been updated

Copy link
Member

@sedghi sedghi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the delay in my review. I have been (and still am) occupied with other tasks. However, I appreciate the fix you provided.

@sedghi sedghi merged commit 70cf339 into cornerstonejs:main Jan 31, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants