将bmp图像转换成DICOM [英] Convert bmp image into DICOM

查看:879
本文介绍了将bmp图像转换成DICOM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有800张BMP格式的图像,我想将它们转换为DICOM。我已经开始这样了,但是由于某些原因它无法正常工作。

I have 800 images in BMP format and I would like to convert them into DICOM. I have started like this, but it is not working for some reason.

我对VTK的使用经验有限:

My experience with VTK is limited:

file_in = 'C:/programfile/image.bmp'
file_out = 'test1.dcm'
vtkGDCMImageReader()


推荐答案

在python中:

r = vtkBMPReader()
r.SetFileName( 'test1.bmp' )

w = vtkGDCMImageWriter()
w.SetInput( r.GetOutput() )
w.SetFileName( 'test1.dcm' )
w.Write()

如果输入的BMP使用查找表,则可以简单地传递它:

If your input BMP uses lookup table, you can simply pass it:

r = vtkBMPReader()
r.SetFileName( 'test1.bmp' )
r.Allow8BitBMPOn()
r.Update()
r.GetOutput().GetPointData().GetScalars().SetLookupTable( r.GetLookupTable() )

w = vtkGDCMImageWriter()
w.SetInput( r.GetOutput() )
w.SetFileName( 'test1.dcm' )
w.SetImageFormat( VTK_LOOKUP_TABLE );
w.Write()

与之相反(DICOM-> BMP):

And the opposite (DICOM -> BMP):

r = vtkGDCMImageReader()
r.SetFileName( 'test1.dcm' )

w = vtkBMPWriter()
w.SetInput( r.GetOutput() )
w.SetFileName( 'test1.bmp' )
w.Write()

当然,您可以从命令行执行,只需使用 gdcm2vtk

Of course you can do it from the command line, simply use gdcm2vtk:

$ gdcm2vtk input.bmp output.dcm

$ gdcm2vtk --palette-color input.bmp output.dcm

这篇关于将bmp图像转换成DICOM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆