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

How to get PixelData? #19

Open
nagayev opened this issue Feb 19, 2023 · 1 comment
Open

How to get PixelData? #19

nagayev opened this issue Feb 19, 2023 · 1 comment

Comments

@nagayev
Copy link

nagayev commented Feb 19, 2023

I need to get and then edit PixelData.

@project-eutopia
Copy link
Owner

What exactly would you like to do? Currently there is only minimal support for editing pixel data. You can get a handle to the underlying pixel data bytes by using the supplied manipulator. If you have a PixelData element (tag 0x7FE0,0x0010), you can get either a manipulator either with:

// If you want an array of `Byte`s (8 bit blocks of pixel data at a time)
data_set->manipulator<vega::dictionary::PixelData_OB>();
// If you want an array of `Word`s (16 bit blocks of pixel data at a time)
data_set->manipulator<vega::dictionary::PixelData_OW>();

To properly understand the content of the pixel data though, you will need to look up the Bits Allocated, Bits Stored, and High Bit elements: https://www.leadtools.com/sdk/medical/dicom-spec17. For instance, if Bits Allocated is 16, then you should work with 16-bit Word pixels. Then, if you want to go between raw pixel values and interpreted values (for instance, density values in CT pixel data), you need to convert from these integers using Rescale Intercept and Rescale Slope: https://stackoverflow.com/questions/10193971/rescale-slope-and-rescale-intercept.

There is room for improvement with this approach, by automatically hiding some of these details, but right now you need to understand how pixel data is stored in the DICOM file to properly interpret and manipulate.

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

No branches or pull requests

2 participants