1

Is it possible to use the Python wrappers for GDCM to decode the image data in a DICOM file?

I have a byte array / string with the bytes of the image data in a DICOM file (i.e. the contents of tag 7fe0,0010 ("Pixel Data")) and I want to decode the image to something raw RGB or greyscale.

I am thinking of something along the lines of this but working with just the image data and not a path to the actual DICOM file itself.

4

1 回答 1

3

您可以阅读示例,其中有一个说明如何将输入的压缩 DICOM 转换为未压缩的 DICOM。在线查看代码:

如果你是 NumPy 的忠实粉丝,请查看:

这是一个低级示例,它显示了如何检索图像的实际原始缓冲区。

一个更好的处理Transfer Syntax转换的类是使用gdcm.ImageChangeTransferSyntax类(允许解压图标)

如果您不介意阅读一点 C++,您可以轻松地将以下代码从 C++ 转换为 Python:

注意这个例子实际上是压缩图像而不是解压缩它。

最后,如果您真的只能访问 Pixel Data 属性中包含的数据值,那么您真的应该看看(C# 语法应该接近 Python 语法):

此示例显示如何解压缩 JPEG 无损、非分层、一阶预测文件。JPEG 数据是从文件中读取的,但如果数据已经在您的内存中,它应该可以工作。

于 2015-01-14T10:10:51.073 回答