extract 16bit data from dicom

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
acl900

extract 16bit data from dicom

Post by acl900 »

Hi
I am trying to extract 16 bit image data from http://sf.anu.edu.au/~acl900/VolumeData/test.dcm .
Using ImageMagick 6.5.8-Q16 on windows, identify.exe reports 16bit depth, but imdisplay.exe
displays only 8bit version of the image. It seems dicom windowing is applied to the data before display as
well as before image.write(). I am using Magick++.

I have been able to extract 16 bit data from the file using version 6.2.9, but that version has a memory leak
(atleast while reading dicom files).

Thanks,
Ajay Limaye
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: extract 16bit data from dicom

Post by magick »

Add
  • defineValue( "dcm", "display-range", "reset");
acl900

Re: extract 16bit data from dicom

Post by acl900 »

Thanks for the immediate reply.

I must be doing something very silly, as I am still not extracting
the actual 16-bit data. Had a look at dcm.c and found that
setting "dcm:display-range" to "reset", sets window_width to 0,
which will give me exactly what I want.

This is what my code looks like (tmp is an unsigned char array):

Code: Select all

      Image img(imageName);
      img.defineValue("dcm", "display-range", "reset");
      img.write(0, 0, img.columns(), img.rows(),"I", ShortPixel, tmp);
Cheers,
Ajay
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: extract 16bit data from dicom

Post by magick »

You need to define the value *before* you read the image. Declare you image, call defineSet() then read your DCM image with image.read().
acl900

Re: extract 16bit data from dicom

Post by acl900 »

Done, thanks,Ajay
Post Reply