[Insight-users] read a meta image and write it to DICOM

Rama Aravind Vorray ramavorray at yahoo.com
Sun Sep 11 14:55:50 EDT 2005


Hi,

If you are looking to solve the error that you are
facing with, I think you need to maintain consistent
data types. Your question doesn't make clear what you
are looking for.

As far as I understood you code, you are reading data
as 'signed int' and you are streaming it into your
'writer1' object which you specified it to maintain
'short' data type.

If your question meant that you are asking for what
type of data type you have to use for writing DICOM
images then answer is variable. But 'unsigned char'
and 'unsigned short' are mostly used type of data
types occasionally switching to 'signed short' where
you have to take care of signed bit (MSB).

Hope this helps.

regards,
Aravind.

--- ³¯¬FÞm <m9421001 at gmail.com> wrote:

> Hi,all ITK user:
> 
> I want to read a meta image(.mhd) and write it to
> DICOM format.
> 
> This is my code for this question:
> 
>
========================================================
> #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<signed int, 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<short, 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;
> 
> }
> 
>
========================================================
> I get a error message as follows:
> 
> error C2664: 'SetInput' : cannot convert parameter 1
> from 'class
> itk::Image<int,3> *' to 'const class
> itk::Image<short,3> *'
> Types pointed to are unrelated; conversion requires
> reinterpret_cast,
> C-style cast or function-style cast
> 
> 
> My question is:
> 
> what format can specify when I  read a META image
> and write it to DICOM?
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the Insight-users mailing list