[Insight-users] I want to fulfill a function with ITK , read from a dcm picture and write to a jpg picture .Please help !

章强 15891495523 at 126.com
Wed Jul 24 04:31:02 EDT 2013


Hello ,   I have just started learning ITK , and I have some difficulty with it .
 Now ,I want to fulfill a function with ITK , read from a dcm picture and write to a jpg picture . My code has some problem ,could you please correct it ? the following is my code :


#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkRescaleIntensityImageFilter.h"
#include "itkGDCMImageIO.h"
#include "itkJPEGImageIO.h"




void main( )
{
  typedef signed short InputPixelType;
  const unsigned int   InputDimension = 2;


  typedef itk::Image< InputPixelType, InputDimension > InputImageType;


  typedef itk::ImageFileReader< InputImageType > ReaderType;


  ReaderType::Pointer reader = ReaderType::New();


  const char * filename = "C:\\Users\\zhq\\Desktop\\data\\SNAP_CR\\E403434298\\E403434298S1901I301.dcm";


  reader->SetFileName( filename );


  typedef itk::GDCMImageIO           ImageIOType;


  ImageIOType::Pointer gdcmImageIO = ImageIOType::New();


  reader->SetImageIO( gdcmImageIO );
  reader->Update();


  typedef itk::ImageFileWriter<InputImageType>  WriteType ;


  WriteType::Pointer write = WriteType::New();


  const char * outfile = "C:\\Users\\zhq\\Desktop\\2.dcm";


  write->SetFileName(outfile);


  typedef itk::JPEGImageIO          OutPutIOType ; 


  OutPutIOType::Pointer jpgIO = OutPutIOType::New();


  write->SetImageIO(gdcmImageIO);


  write->SetInput(reader->GetOutput());


  write->Update();
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130724/cb3bd2f1/attachment.htm>


More information about the Insight-users mailing list