[Insight-users] read a meta image and write a volume to DICOM
wordon
m9421001 at gmail.com
Thu Sep 15 12:11:53 EDT 2005
It's so sorry to post the message agian.
Because i meet some trouble when I post the letter.
It's the post previously.
======================================================
Hi,
You need set IOImage on the reader withi dicomIO (GDCMImageIO).
The difference difference between series and volume is that the serie is for
example
IMR001.bmp
IMR002.bmp
IMR002.bmp
.
.
.
and the volume can be dicom multiframes or mhd format or raw format that
they have
a data 3Dmatrix whit the imaga slices.
The Dicom format can be mono frame and multiframe.
2005/9/15, ê�ÕþŸ˜ <m9421001 at gmail.com>:
>
> Hi,Luis and all ITK user:
>
> I want to read a meta image and use the data '
> BrainProtonDensity3Slices.mha' & ' BrainProtonDensity3Slices.raw ' in
> Insight\Examples\Data.
> ( I want to read a 3D raw image )
>
> And then wirte the meta image into a volume of DICOM format.
> (.mhd or .mha --> .dcm)
>
>
> My code as follows :
>
> #include "itkImageFileReader.h"
> #include "itkImageFileWriter.h"
> #include "itkImage.h"
> #include "itkRescaleIntensityImageFilter.h"
> #include "itkMetaDataDictionary.h"
> #include "itkMetaDataObject.h"
> #include "itkGDCMImageIO.h"
>
> #include <list>
> #include <fstream>
>
> int main(int ac, char* av[])
> {
>
> if(ac < 3)
> {
> std::cerr << "Usage: " << av[0] << " InputMETAFile OutputDICOM\n";
> return EXIT_FAILURE;
> }
>
> typedef itk::Image<unsigned char, 3> ImageType;
>
> typedef itk::ImageFileReader< ImageType > VolumeReaderType;
>
> VolumeReaderType::Pointer reader = VolumeReaderType::New();
>
> reader->SetFileName( av[1] );
>
> try
> {
> reader->Update();
> }
> catch (itk::ExceptionObject & e)
> {
> std::cerr << "exception in file reader " << std::endl;
> std::cerr << e.GetDescription() << std::endl;
> std::cerr << e.GetLocation() << std::endl;
> return EXIT_FAILURE;
> }
>
>
> typedef itk::GDCMImageIO ImageIOType;
>
> ImageIOType::Pointer gdcmImageIO = ImageIOType::New();
>
>
> typedef itk::Image<unsigned char, 3> WriteType;
> typedef itk::ImageFileWriter<WriteType> Writer1Type;
> Writer1Type::Pointer writer1=Writer1Type::New();
>
> writer1->SetFileName( av[2] );
> writer1->SetImageIO( gdcmImageIO );
> writer1->SetInput( reader->GetOutput() );
>
>
> try
> {
> writer1->Update();
> }
> catch (itk::ExceptionObject & e)
> {
> std::cerr << "exception in file writer " << std::endl;
> std::cerr << e.GetDescription() << std::endl;
> std::cerr << e.GetLocation() << std::endl;
> return EXIT_FAILURE;
> }
>
>
>
> return EXIT_SUCCESS;
>
> }
>
> My code can run,but the DICOM image in output is not correctly.
> It has a problem like loss some information in output file.
>
> My questions:
> 1)Is it right to read the 3D meta image use ImageFileReader directly?
> 2)Is it right to write the data into a volume of DICOM use
> ImageFileWriter directly?
> 3)What are difference between series and volume?
> 4)If I want to get a 3D DICOM file in one file.Is it a volume?
>
> Thanks a lot. : -)
> Wordon
===================================================
I really thanks for Diego Parada help.
But when I try to fix my code as follows:
==============================================
typedef itk::GDCMImageIO ImageIOType;
ImageIOType::Pointer gdcmImageIO = ImageIOType::New();
typedef itk::Image<unsigned char, 3> ImageType;
typedef itk::ImageFileReader< ImageType > VolumeReaderType;
VolumeReaderType::Pointer reader = VolumeReaderType::New();
reader->SetImageIO( gdcmImageIO );
reader->SetFileName( av[1] );
.
.
reader->Update();
.
.
===============================================
I get a 'error' as this :
Error :
exception in file reader
itk::ERROR: GDCMImageIO(003D2448): Unrecognized type:0S in file
BrainProtonDensity3Slices.mha
Unknown
is it wrong in my code?
More information about the Insight-users
mailing list