[Insight-users] DICOM TO RAW

Ocean Spring meancity at gmail.com
Tue Jul 22 04:57:56 EDT 2008


hello,

there are actually well developed tools to do this , please refer

http://barre.nom.fr/medical/dicom2/

the software name is dicom2. it is free to use under windows/DOS
environment.

cheers

OS.
www.vislab.cn/bbs

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上小游戏,工作休闲两不误! 马上就开始玩! <http://im.live.cn/minigame>
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
>


-- 
---------
www.vislab.cn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20080722/ffa99a9b/attachment-0001.htm>


More information about the Insight-users mailing list