Copy Header Tags on copy DcmDataset

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
focus
Posts: 77
Joined: Wed, 2005-03-16, 20:29
Location: Catalonia

Copy Header Tags on copy DcmDataset

#1 Post by focus »

Hello,

I would like to now if there is a way to copy from DcmDataset with pixeldata only the Dicom Header Data.

We have a DcmDataset

Code: Select all

DcmDataset dataset1;
dataset1 is a DcmDataset with pixel data, then using the constructor of DcmDataset we copy dataset1 object
Dcmdataset dataset2 = DcmDatset(dataset1);
In dataset2 we only need the dicom data header no the pixel data.

To save memory there is a way to make a copy of dcmdataset1 without pixel data ?

Thanks.

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

#2 Post by Michael Onken »

Hi,

there is no copy constructor which permits not to copy pixel data; also note that there may be other elements besides pixel data (like overlays, LUT data, ...) which may be larger than "normal" elements.

What you can do before performing the copy: Remove the pixel data (but not delete it, copy the dataset and re-insert the pixel data. Something like this:

Code: Select all

DcmElement* rememberPixelData = dataset->remove(DCM_PixelData);
if (elem == NULL)
  return EC_IllegalCall; // no pixel data in dataset?!

DcmDataset* copyWithoutPixelData= new DcmDataset(dataset);
if (copyWithoutPixelData == NULL)
  return EC_MemoryExhausted; // not enough memory?

OFCondition result = dataset->insert(rememberPixelData);
if (result.bad())
  return EC_IllegalCall; // something went wrong...
I did not test that so there may be typos but I think the approach should work.

Best regards,
Michael

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest