-
Notifications
You must be signed in to change notification settings - Fork 113
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
improvement: Add pixel data manipulation feature (#169) #182
base: master
Are you sure you want to change the base?
Conversation
* Decode pixel data according to the transfer syntax uid. * Draw rectangle in the pixel * Encode pixel data (only has a skeleton at the moment)
Forgot to mention the supported transfer syntax uids.
|
This looks really good @WoonchanCho 👍 I wonder if copying with attribution as you have done is the best approach as opposed to referencing an upstream package, whereby it might be easier to manage versioning. E.g. did you look at these? https://github.com/chafey/dicom-codec-js ? Perhaps @chafey can advise on a strategy here. |
@pieper, |
There is a lot of good logic in cornrestoneWADOImageLoader that should be refactored out and away from cornerstoneJS so it can be re-used. dicom-codec-js is one step in that direction and @dannyrb is doing something similar here: https://github.com/cornerstonejs/codecs. |
Thank you so much for the info @chafey. I will take a look at the library further, but I think, (at least) in a long run, your dicom-codec-js fits better for dcmjs because it abstracts the dependencies on the parsing libraries, making it easy to use the with objects parsed with dcmjs. Also, dicom-codec-js takes (will take) care of encoding which we will need to use to encode back to the original form after modifying pixels. |
@pieper, chafey's library is not pushed to npm registry yet, chafey and dannyrb will connect and merge their two separate libraries: chafey/dicom-codec-js#1 |
Those guys are both very good so It would be great to use their packages unless they don't have a chance to wrap things up and you need the features sooner. Rather than implementing a workaround here is there anything you can do to help them get their stuff finished up? |
@WoonchanCho give us more than a few hours to figure this out :) |
@pieper got it, the existing two libraries are not ready for us to use for some reasons (e.g, not being pushed to the npm registry) although I can manually handle the issues and use either of them. I will wait till chafey and dannyrb will decide something. |
- add allowInvalidVRLength (false by default) in the write options - add a test case for testing this option
Hi @pieper and maintainers,
This is my first effort for implementing DICOM pixel manipulation.
All the related sources for this feature are under new folders (/src/pixelModifier and /libs).
In the current version, you can draw a rectangle (to hide PHI in most cases)
...
const dicomDict = DicomMessage.readFile(buffer);
const pixelModifier = new PixelModifier(dicomDict);
pixelModifier.draw("rectangle", { left:100, top, 200, right: 200, bottom: 200});
...
The /src/pixelModifer consists of three part
Many of the sources for decoding have been ported from https://github.com/cornerstonejs/cornerstoneWADOImageLoader, which looks very stable.
Currently only "drawing rectangle" is supported but other shapes can be easily added when needed.
Encoding is not fully implemented yet. All the decoded pixels will be saved to ExplicitVRLittleEndian.
What to do next would be