[Insight-users] DICOM TO RAW

Daniele Domenichelli daniele.domenichelli at gmail.com
Thu Jul 17 05:18:17 EDT 2008


Hello Gjtian,

Amide can probably read orientation of the image from DICOM header,
but raw data doesn't have information about orientation.
You should consider using another file format or reorienting your
images before writing them

Regards,
 Daniele

2008/7/16 田光建 <gjtian at hotmail.com>:
> Dear ALL,
> I want to convert DICOM image into raw format,I use amide to display my
> image. Before the format transformation, the DICOM image can be displayed in
> amide correctly, but after the format transformation, the patient's head
> will be in bottom in raw data displyed in amide. The following are the
> source codes:
>
> #if defined(_MSC_VER)
> #pragma warning ( disable : 4786 )
> #pragma warning ( disable : 4996)
> #endif
>
> #include "itkImage.h"
> #include "itkOrientedImage.h"
> #include "itkGDCMImageIO.h"
> #include "itkGDCMSeriesFileNames.h"
> #include "itkImageSeriesReader.h"
> #include "itkImageFileWriter.h"
>
> int main( int argc, char *argv[] )
> {
>     const    unsigned int    ImageDimension = 3;
>     typedef  signed short    PixelType;
>     typedef itk::Image< PixelType, ImageDimension >  ImageType;
>     typedef itk::OrientedImage< PixelType, ImageDimension  >
> ImageReaderType;
>     typedef itk::ImageSeriesReader< ImageReaderType >        ReaderType;
>     ReaderType::Pointer  ImageReader  = ReaderType::New();
>     typedef itk::GDCMImageIO       ImageIOType;
>     ImageIOType::Pointer dicomIO = ImageIOType::New();
>     ImageReader->SetImageIO( dicomIO );
>     typedef itk::GDCMSeriesFileNames NamesGeneratorType;
>     NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();
>     nameGenerator->SetUseSeriesDetails( true );
>     nameGenerator->AddSeriesRestriction("0008|0021" );
>     nameGenerator->SetDirectory( argv[1] );
>     typedef std::vector< std::string >    SeriesIdContainer;
>     const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();
>     SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();
>     SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();
>     while( seriesItr != seriesEnd )
>     {
>         std::cout << "input image series:" << std::endl;
>         std::cout << seriesItr->c_str() << std::endl;
>         seriesItr++;
>     }
>     std::string seriesIdentifier;
>     seriesIdentifier = seriesUID.begin()->c_str();
>     std::cout << std::endl << std::endl;
>     std::cout << "Now reading series: " << std::endl << std::endl;
>     std::cout << seriesIdentifier << std::endl;
>     std::cout << std::endl << std::endl;
>     typedef std::vector< std::string >   FileNamesContainer;
>     FileNamesContainer ImagefileNames;
>     ImagefileNames = nameGenerator->GetFileNames( seriesIdentifier );
>     ImageReader->SetFileNames(ImagefileNames);
>     ImageType::ConstPointer inputImage = ImageReader->GetOutput();
>     try
>     {
>         ImageReader->Update();
>     }
>     catch (itk::ExceptionObject &err)
>     {
>         std::cerr << "ExceptionObject caught !" << std::endl;
>         std::cerr << err << std::endl;
>         return EXIT_FAILURE;
>     }
>     typedef itk::ImageFileWriter< ImageType > ImageFileWriterType;
>     ImageFileWriterType::Pointer writer = ImageFileWriterType::New();
>     writer->SetInput( inputImage );
>     writer->SetFileName( argv[2] );
>     try
>     {
>         writer->Update();
>     }
>     catch (itk::ExceptionObject &err)
>     {
>         std::cerr << "ExceptionObject caught !" << std::endl;
>         std::cerr << err << std::endl;
>         return EXIT_FAILURE;
>     }
>     return EXIT_SUCCESS;
> }
>
> ________________________________
> MSN上小游戏,工作休闲两不误! 马上就开始玩!
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
>


More information about the Insight-users mailing list