Convert bmp image into DICOM

﹥>﹥吖頭↗ 提交于 2019-12-24 00:58:17

问题


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.

My experience with VTK is limited:

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

回答1:


Here it is in python:

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

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

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()

And the opposite (DICOM -> BMP):

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

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

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

$ gdcm2vtk input.bmp output.dcm

or

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



回答2:


If you are using C++ there are other libraries DICOM file libraries. Check out DCMTK, specifically one of their example application already does this for you. http://support.dcmtk.org/docs-dcmrt/img2dcm.html



来源:https://stackoverflow.com/questions/5035078/convert-bmp-image-into-dicom

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!