DICOM Image saving

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
Ashok
Posts: 2
Joined: Sat, 2004-12-18, 08:39
Location: India
Contact:

DICOM Image saving

#1 Post by Ashok »

hello...

iam looking for a method to save dicom images....

iam having all the image attributes in hand and i need to fill in the attributes of the dicom image and save the dicom image.....

i tried to create a DcmDataset and add all the attributes.....and then i passed the pointer to Dataset as parameter to DCM FileFormat constructor......

from the DCMFileFormat object pointer i tried to call the SaveFile Method..

but iam not able to get the resultant file....

some file is written with out any data on it(0 bytes)...

could some one help me on this.....

some other method to do this will be even more helpful.....

Thanks in advance,
ashok

Jörg Riesmeier
ICSMED DICOM Services
ICSMED DICOM Services
Posts: 2217
Joined: Fri, 2004-10-29, 21:38
Location: Oldenburg, Germany

#2 Post by Jörg Riesmeier »

The following example shows how to create a DICOM dataset and save it to a file:

Code: Select all

char uid[100];
DcmFileFormat fileformat;
DcmDataset *dataset = fileformat.getDataset();
dataset->putAndInsertString(DCM_SOPClassUID, UID_SecondaryCaptureImageStorage);
dataset->putAndInsertString(DCM_SOPInstanceUID, dcmGenerateUniqueIdentifier(uid, SITE_INSTANCE_UID_ROOT));
dataset->putAndInsertString(DCM_PatientsName, "Doe^John");
/* ... */
dataset->putAndInsertUint8Array(DCM_PixelData, pixelData, pixelLength);
OFCondition status = fileformat.saveFile("test.dcm", EXS_LittleEndianExplicit);
if (status.bad())
  cerr << "Error: cannot write DICOM file (" << status.text() << ")" << endl;
Btw, this example is part of the toolkit's HTML documentation.

Ashok
Posts: 2
Joined: Sat, 2004-12-18, 08:39
Location: India
Contact:

Thanks

#3 Post by Ashok »

thanks Jörg Riesmeier,

that was really helpful....

:D
Ashok

Post Reply

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest