Giter Club home page Giter Club logo

Comments (7)

dicom avatar dicom commented on August 27, 2024

It seems that it is actually possible to compile ImageMagick to support these more obscure jpeg variants that it doesn't support out of the box, by including some custom 'delegate' jpeg libraries. For reference, have a look at a discussion of the topic here:

http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=23249

If anyone is successful in building ImageMagick to enable these files, e.g. this one (https://github.com/dicom/ruby-dicom/raw/master/samples/explicit_ct_jpeg-lossless-nh_mono2.dcm), it would be awesome if you could post your recipe here.

from ruby-dicom.

nark avatar nark commented on August 27, 2024

Hi,

Just to point this page: https://code.google.com/p/openjpeg/wiki/GSOC_2013 where users are talking about openjpeg bindings for ImageMagick delegate. Openjpeg currently seems to be the best candidate to handle every JPEG2000 variants, unfortunately after several tries with ImageMagick and custom delegate, I'm not able to provide a working solution, yet. I keep trying.

from ruby-dicom.

kuronae12 avatar kuronae12 commented on August 27, 2024

Hi Christoffer,

I'm trying to decompress the transfer syntax "1.2.840.10008.1.2.4.91 - JPEG 2000 Image Compression (Lossless or Lossy)", but I get an error from the DObject saying that "DICOM: Decompressing the Pixel Data failed. Pixel values can not be extracted."

I already enabled support on ImageMagick for JPEG2000 compression algorithms and actually I'm able to convert the DICOM files if I use the "convert" tool from ImageMagick directly, so ImageMagick and Rmagick are not the problem here.

The DObject hash representation gives me this:

"Samples per Pixel"=>1, "Photometric Interpretation"=>"MONOCHROME2", "Rows"=>512, "Columns"=>512, "Pixel Spacing"=>"0.885\\0.885", "Bits Allocated"=>16, "Bits Stored"=>16, "High Bit"=>15, "Pixel Representation"=>1, "Window Center"=>"40", "Window Width"=>"400", "Rescale Intercept"=>"0", "Rescale Slope"=>"1", "Lossy Image Compression"=>"01", "Lossy Image Compression Ratio"=>"1", "Scheduled Procedure Step Start Date"=>"20180210", "Scheduled Procedure Step Start Time"=>"111206.000", "Scheduled Procedure Step End Date"=>"20180210", "Scheduled Procedure Step End Time"=>"114206.000", "Performed Procedure Step Start Date"=>"20180210", "Performed Procedure Step Start Time"=>"111206.000", "Performed Procedure Step ID"=>"3838", "7005,0010"=>nil, "7005,1007"=>nil, "7005,1008"=>nil, "7005,1009"=>nil, "7005,100A"=>nil, "7005,100B"=>nil, "7005,100D"=>nil, "7005,100E"=>nil, "7005,100F"=>nil, "7005,1012"=>nil, "7005,1013"=>nil, "7005,1016"=>nil, "7005,1017"=>nil, "7005,1018"=>nil, "7005,1019"=>nil, "7005,101A"=>nil, "7005,101B"=>nil, "7005,101D"=>nil, "7005,101E"=>nil, "7005,101F"=>nil, "7005,1020"=>nil, "7005,1021"=>nil, "7005,1022"=>nil, "7005,1023"=>nil, "7005,1024"=>nil, "7005,1030"=>nil, "7005,1040"=>nil, "Encapsulated Pixel Data"=>{"Item 0"=>{"Item 0"=>{"Pixel Data Item"=>nil}}}}

So, I see that actually the DObject doesn't get any pixel data information from the DICOM file. Do you know what might be the problem and point me to the correct part of the code in order to fix it?

At this point I'm going to use Rmagick to convert those DICOM files and see if I can find the problem within the ImageItem and DObject classes, but any help pointing me to the correct direction is greatly appreciated.

Regards

from ruby-dicom.

dicom avatar dicom commented on August 27, 2024

Hi kuronae, thanks for your interest!

I would suggest checking out image_item.rb:
https://github.com/dicom/ruby-dicom/blob/master/lib/dicom/image_item.rb

Start with the #image and #images methods.

Then you'd probably have to have a look in the image_process.rb file:
https://github.com/dicom/ruby-dicom/blob/master/lib/dicom/image_processor.rb

Specifically the #decompress method.

This again calls the #decompress method in the image_process_r_magick.rb file:
https://github.com/dicom/ruby-dicom/blob/master/lib/dicom/image_processor_r_magick.rb

That should get you started I think. Happy hunting!

Best regards,
Christoffer

from ruby-dicom.

kuronae12 avatar kuronae12 commented on August 27, 2024

Hi Christoffer,

Thank you for the directions! I managed to track down the bug, and it happens to be Rmagick, there's a bug in decompressing images using the new ImageMagick versions 7.0.7-22 with JPEG2000 support. So I switched the image processor to MiniMagick which happens to be much more updated and maintained than Rmagick, made a couple of changes in the service code that helps me convert the DICOM files and now my service is working as expected :D

Thanks for the help and for creating this amazing tool, I'm creating a service based on RubyDicom. I'll try to factorize some code and add Celluloid support to the DServer and DClient classes in order to make it more stable even though it may not be that necessary, my server has been running for a couple of days without problems, no memory leaks and it's been receiving +100,000 images a day, so I must say that it's pretty stable at this moment.

Best regards,
Jose

from ruby-dicom.

dicom avatar dicom commented on August 27, 2024

Wow, that's encouraging to hear, thank you for this nice feedback. I am happy to hear that you are finding this tool useful.

Of course any contributions will be most welcome!

from ruby-dicom.

ashramsey avatar ashramsey commented on August 27, 2024

made a couple of changes in the service code that helps me convert the DICOM files and now my service is working as expected :D

Hey Jose,

I'm using MiniMagick and am experiencing the error: unsupported transfer syntax: '1.2.840.10008.1.2.4.70' - JPEG Lossless.

Could you please provide some details of what changes you made to your service code to get it working?

Thanks,
Ash

from ruby-dicom.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.