本文介绍了无法获取dicom图像以便在python中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在opencv-python中显示DICOM图像。我正在使用pydicom库,然后添加API以创建一个完整的DICNET DICOM查看器,运行python(C#调用python与流程实例当然!!)。我无法转换或看到未压缩的DICOM图像。每当我尝试加载或修改pixel_array时。我得到错误消息。

I'm trying to display a DICOM image in opencv-python.I am using the pydicom library,And then adding API's to create a full fledged DICOM viewer with DOTNET, that runs python(C# calls python with process instance of course!!). I am unable to convert or see the uncompressed DICOM image. whenever i try to load or modify the pixel_array. I get error messges.

import dicom
import cv2
import numpy
df=dicom.read_file("IM-0001-0002.dcm")
df.pixel_array

Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
df.pixel_array
File "C:\Python27\lib\site-packages\dicom\dataset.py", line 394, in pixel_array
return self._get_pixel_array()
File "C:\Python27\lib\site-packages\dicom\dataset.py", line 376, in _get_pixel_array
raise NotImplementedError("Pixel Data is compressed in a format pydicom does not yet          handle. Cannot return array")
NotImplementedError: Pixel Data is compressed in a format pydicom does not yet handle.        Cannot return array

请建议我转换图片的好方法制作cv2.imshow()函数o display图像

Please suggest me good way to convert the image making cv2.imshow() function o display the image

先谢谢!!

推荐答案

你可以使用首先解压缩文件的python GDCM绑定,例如参见

You can use the python GDCM binding to decompress the file first, see for example here

这篇关于无法获取dicom图像以便在python中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 22:40