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

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -