FAQ #34: Is there a tool that converts common graphic formats to DICOM?

Frequently Asked Questions regarding DCMTK

Moderator: FAQ Team

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

FAQ #34: Is there a tool that converts common graphic formats to DICOM?

#1 Post by Jörg Riesmeier »

:?: Is there a tool that converts common graphic formats like PGM/PPM, PNG, TIFF, JPEG or BMP to DICOM?

:!: No, unfortunately, there is no such tool in DCMTK. Currently, you have to write your own little program for that purpose.

The following code snippet from the toolkit's documentation could be a starting point:

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;
The current snapshot of the DCMTK (> version 3.5.4) contains a new command line tool "img2dcm" that allows for converting JPEG images to certain DICOM image SOP classes.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest