[Insight-users] Re: ITK file write error

Luis Ibanez luis.ibanez at kitware.com
Sat Sep 11 13:40:27 EDT 2004


Hi Nawab,

Please read the IO chapter on the SoftwareGuide

   http://www.itk.org/ItkSoftwareGuide.pdf

Chapter 7, pdf-page 219-240. That will help you to understand
how the Reading/Writing architecture works in ITK.


You should also read the FAQ, there is an entry regarding
this specific error message.

It simply indicates that ITK has not recognized the
fileformat of your file.


In your particular case, you are attempting to write
a DICOM file. the DICOMImageIO and DICOMImageIO2 classes
in ITK *do not support writing DICOM*, they only read from
DICOM.

If writing DICOM is fundamental for your application, you
may want to try installing "gdcm" and using it from ITK.
You will have to download and build gdcm in your system.
Then rerun CMake on ITK, go to Advanced options and
enable USE_GDCM. Then rebuild ITK.

After that you will be able to use the GDCMImageIO object
in order to write DICOM files.


You will find examples on the use of GDCMImageIO in the
directory

                Insight/Examples/IO

For this you should use a CVS version of ITK, since multiple
changes have been made recently to these classes.



    Regards,



       Luis



--------------------------
Nawab Singh Baghel wrote:

> Hi Luis,
> 
> When I run this program to read dicom file and write. It gives
> Imagefilewriter(0122DDF8) no imageIO set or none could be created
> 
> please advise what is wrong in this code
> 
> #include "itkImage.h"
> #include "itkImageFileReader.h"
> #include "itkImageFileWriter.h"
> 
> void CItkMFCDoc::OnFileOpen()
> {
>   CString strFilter;
>   typedef itk::Image< unsigned short, 2 > ImageType;
>   typedef itk::ImageFileReader< ImageType > ImgReaderType;
>   typedef itk::ImageFileWriter< ImageType >  WriterType;
> 
>   ImgReaderType::Pointer reader = ImgReaderType::New();
>   WriterType::Pointer writer = WriterType::New();
> 
> 
> 
>   strFilter = "MetaImage|*.mhd;*.mha|Analyze|*.hdr|VTK
> Image|*.vtk|JPEG|*.jpeg|TIFF Image|*.tiff|PNG Image|*.png|GIPL
> Image|*.gipl||";
> 
>   CFileDialog dlg(TRUE, NULL, NULL, OFN_FILEMUSTEXIST, strFilter);
> 
>   HRESULT hResult;
>   hResult = (int)dlg.DoModal();
>   if( hResult != IDOK )
>     {
>     return;
>     }
>  reader->SetFileName(dlg.GetFileName());
>  writer->SetFileName("d:\\11.dcm");
> 
>  writer->SetInput( reader->GetOutput() );
>   try
>     {
>     writer->Update();
>     }
>   catch( itk::ExceptionObject & excp )
>     {
>     CString fmt;
>     fmt.Format("Load image failed:\n%s",excp.GetDescription() );
>     ::AfxMessageBox(fmt);
>     }
> }
> 
> Regards
> Nawab
> 
> 
> 






More information about the Insight-users mailing list