我在 vtkImageData 中保存了一个卷图像,需要将其转换为 DcmDataset (DCMTK)。我知道我需要将患者数据等一般 DICOM 标签设置为数据集。那不是问题。 特别是我对将像素数据放入 DcmDataset 感兴趣。有没有人知道一个例子或可以解释如何做到这一点?
提前致谢
最佳答案
引自DCMTK FAQ :
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:
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.
我可能会先查看 img2dcm ( documented here ) 的源代码以了解一般过程,然后再回贴任何具体问题。恕我直言,DCMTK 非常强大但极难理解。
关于c++ - vtkImageData 到 DcmDataset,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21162890/