我有 800 张 BMP 格式的图像,我想将它们转换成 DICOM。我是这样开始的,但由于某种原因它不起作用。
我对 VTK 的经验有限:
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 使用查找表,您可以简单地传递它:
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):
r = vtkGDCMImageReader()
r.SetFileName( 'test1.dcm' )
w = vtkBMPWriter()
w.SetInput( r.GetOutput() )
w.SetFileName( 'test1.bmp' )
w.Write()
当然你可以从命令行来做,简单地使用gdcm2vtk :
$ gdcm2vtk input.bmp output.dcm
或
$ gdcm2vtk --palette-color input.bmp output.dcm
