python - Convert bmp image into DICOM -
i have 800 images in bmp format , convert them dicom. have started this, not working reason.
my experience vtk limited:
file_in = 'c:/programfile/image.bmp' file_out = 'test1.dcm' vtkgdcmimagereader()
here in python:
r = vtkbmpreader() r.setfilename( 'test1.bmp' ) w = vtkgdcmimagewriter() w.setinput( r.getoutput() ) w.setfilename( 'test1.dcm' ) w.write()
if input bmp uses lookup table, can 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 opposite (dicom -> bmp):
r = vtkgdcmimagereader() r.setfilename( 'test1.dcm' ) w = vtkbmpwriter() w.setinput( r.getoutput() ) w.setfilename( 'test1.bmp' ) w.write()
of course can command line, use gdcm2vtk:
$ gdcm2vtk input.bmp output.dcm
or
$ gdcm2vtk --palette-color input.bmp output.dcm
Comments
Post a Comment