Read buggy 16/11 Bit CT Image

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
christian
Posts: 7
Joined: Thu, 2006-06-08, 14:50

Read buggy 16/11 Bit CT Image

#1 Post by christian »

Hello,

we using the following code to read dicom images. This worked
well for all kind of images (color, grayscale, 8-16 Bit ...).

DicomImage *di = new DicomImage(dfile, xfer, CIF_AcrNemaCompatibility, 0, 1);
DicomImage::getString(di->getStatus();

Now we have some uncompressed dicom images on a CD that show the following error:

ERROR: invalid values for 'BitsAllocated' (16), 'BitsStored' (16) and/or 'HighBit' (11) !

So this file is buggy but we need to read it. Since it is uncompressed we just stripped of
the header and worked with the raw data - but this is ugly.
Is there any way to bypass the dcmtk check e.g. by setting the HighBit to 15 ?

Best regards,
Christian

Michael Onken
DCMTK Developer
Posts: 2055
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

#2 Post by Michael Onken »

Hi Christian,

As far as I know (and Jörg, the author of DcmImage, is not in the office currently :wink: ) would say there is no way of tweaking DcmImage for ignoring those wrong High Bit settings.

Actually you should correct the file before throwing it into DcmImage. You might use dcmodify to change the HighBit value to the value you need, e.g.

Code: Select all

dcmodfiy -m HighBit="15" your-file.dcm 
Regards,
Michael

christian
Posts: 7
Joined: Thu, 2006-06-08, 14:50

#3 Post by christian »

[quote="Michael Onken"]Hi Christian,

As far as I know (and Jörg, the author of DcmImage, is not in the office currently :wink: ) would say there is no way of tweaking DcmImage for ignoring those wrong High Bit settings.

Actually you should correct the file before throwing it into DcmImage. You might use dcmodify to change the HighBit value to the value you need, e.g.

[code]dcmodfiy -m HighBit="15" your-file.dcm [/code]

thank you for your help. This works when I copy the files from the CD to the disk first.
But the application should be able to read the files from the CD.
Can this change be made in memory (within DcmFileFormat *dfile) as well ?

Best regards,
Christian

Michael Onken
DCMTK Developer
Posts: 2055
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

#4 Post by Michael Onken »

Yes of course!

Take a look at the functions provided by DcmItem. Open the file, get the dataset (a DcmItem) and call the putAndInsert... functions to insert / modify tags and values.

A short example can be found in the DCMTK documentation of module dcmdata (online here).
This should do the trick:

Code: Select all

DcmFileFormat fileformat;
OFCondition status = fileformat.loadFile("test.dcm");
if (status.good())
{
  OFString patientsName;
  if (fileformat.getDataset()->putAndInsertUint16(DCM_HighBit, 15)
  {
    cout << "Changed High Bit to 15, saving test.dcm" << OFendl;
    fileFormat.saveFile("test.dcm"); 
  } else
    cerr << "Error: cannot insert/change value of High Bit" << OFendl;
} else
  cerr << "Error: cannot read DICOM file (" << status.text() << ")" << OFendl;

Done :-) I did not compile that, but you see how it should work...

Have a nice weekend with DCMTK :lol:
Michael

christian
Posts: 7
Joined: Thu, 2006-06-08, 14:50

#5 Post by christian »

[quote="Michael Onken"]Yes of course!

Done :-) I did not compile that, but you see how it should work...

Michael[/quote]

Yes, not it works. Thanks again for your help. You saved my weekend :)

Best regards,
Christian

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest