c++ - vtkImageData 到 DcmDataset

标签 c++ vtk

我在 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/

相关文章:

c++ - 为什么链表不是线程安全的?

c++ - 以另一种方式读取数组 2 维 C++

c++ - vtkSmartPointer 数组

c++ - VTK + Cmake-> USE_VTK_RENDERING错误

c++ - 更改 QHeaderView 数据

c++ - 从没有sstream c++的字符串中提取整数

c++ - 在底部设置运行进程

python - 如何旋转 vtkVectorText 使其面向某个方向?

python - 我在哪里可以找到 python 的 vtk 文档?

mesh - 使用来自点和法线的 vtk 对曲面进行三角测量