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

Help Exporting Dicom to 16-bit Jpeg... #783

Closed
bcallister opened this issue Jan 17, 2019 · 5 comments
Closed

Help Exporting Dicom to 16-bit Jpeg... #783

bcallister opened this issue Jan 17, 2019 · 5 comments
Labels

Comments

@bcallister
Copy link

I have a 16-bit source dicom file loaded into a DicomImage. Whenever I export this image via .RenderImage(), I get an 8-bit Jpeg file. However, I would like to retain all the pixel information because I need to be able to display the full window / level data inside my target application, just like a traditional dicom viewer would support. This is not working properly and I assume its because the created Jpeg is 8-bit (verified) instead of 16-bit, so I have lost much of the information. Can someone tell me how to export the Jpeg so the full pixel data is retained? Many thanks.

@gofal
Copy link
Contributor

gofal commented Jan 17, 2019

The RenderImage is intended to create something, that can be displayed on a screen - currently they all are still 8bit per color channel. And so is jpeg. Does jpeg support 16bit? never heard about it, would be great if you could show me some links. I only know from digital cammera raw formats of 16 or 32 bit.

Anyway: There are 2 possibilities you have:

The intended is, that you just use fo-dicom. The DicomImage has two properties called WindowWidth and WindowLevel. Before calling .RenderImage you set the properties to the desired values and then the rendered image shows you the right result. When the user interacts and changes windowing (level or with) then update the property and call .RenderImage again.

Or if you want to do the windowing pipeline yourself, you can extract the original pixelarray from the dicomImage and then process it yourself as you like. Mia-san has provided some code how to the the raw pixels as uncompressed, in case your DicomFile is stored in a compressed Transfer syntax.

@gofal gofal added the question label Jan 17, 2019
@bcallister
Copy link
Author

bcallister commented Jan 17, 2019

Thank you very much for your help and insights. I am no expert here. A few searches online indicate Jpeg 2000 supports 16-bit, but not widely used. Windows APIs look shady on it's support also.

I know with 8-bit, we can only show up to 256 shades of gray? So how does fo-dicom translate a much wider range of grayscale values to this much smaller range (after setting the width and level properties)? I guess this is what I am confused about?

I like the idea of using fo-dicom for this. In my application, I need to also apply pixel coloring to value ranges while the user scrolls through the images. Does fo-dicom support a pixel pipeline of some sort when .RenderImage() is called that I can hook into in order to keep performance good? I need to be able to apply window/level + colorization in realtime as the user scrolls. Please advise?!

@gofal
Copy link
Contributor

gofal commented Jan 17, 2019

Right, Jpeg2000 can handle 8, 12 and 16bit. Thats the compression where lots of DICOM images are compressed with, but thats nothing that windows or webbrowsers etc can handle.

fo-dicom uses the windowing pipeline that is defined in DICOM standard. This is important, since a DICOM viewer has to guarantee that the image are rendered exactly as it is intended.
Coloring can be archived by a LUT, that is a array of colors where the gray value of n is mapped to the n-th entry of the array.
This all should be fast enough to be performed in realtime.

Since this is no issue (bug, enhancement etc), I would recommend to coninue on gitter (https://gitter.im/fo-dicom/fo-dicom), which is a more active board to ask questions.

@gofal
Copy link
Contributor

gofal commented Jan 17, 2019

@gofal
Copy link
Contributor

gofal commented Mar 27, 2019

Will close this now, if there are still some issues or questions please feel free to reopen this issue.

@gofal gofal closed this as completed Mar 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants