[ITK-users] [ITK] Exception when running IO example ImageReadCastWrite in Xcode
Matt McCormick
matt.mccormick at kitware.com
Wed Apr 2 11:06:48 EDT 2014
Hi Ramon,
> So your example registers one factory, right?
It registers two factories. One for MetaImage, and one for PNG.
> The lines below are
> responsible for that?
>
> itk::ObjectFactoryBase::CreateAllInstance( "itkImageIOBase" );
This does not do the registration. It just lists what is registered.
> ...
> itk::MetaImageIOFactory::RegisterOneFactory();
This registers a MetaImageIO object.
>
> I took the file Code.cxx and built it in an Xcode project and linked to the
> ITK libs. I ran it, passing it an Analyze hdr file and got the following
> exception:
>
> When CMake is not used to register the IO classes, there are
> 0 IO objects available to the ImageFileReader.
>
> When we try to read a MetaImage, we will fail.
>
> After registering the MetaImageIO object, there are
> 1 IO objects available to the ImageFileReader.
>
> Now, when we try to read a MetaImage, we will Error:
> itk::ImageFileReaderException (0x100404798)
> Location: "virtual void itk::ImageFileReader<itk::Image<unsigned char,
> 2>, itk::DefaultConvertPixelTraits<unsigned char>
>>::GenerateOutputInformation() [TOutputImage = itk::Image<unsigned char, 2>,
> ConvertPixelTraits = itk::DefaultConvertPixelTraits<unsigned char>]"
> File: /temp/itk/Modules/IO/ImageBase/include/itkImageFileReader.hxx
> Line: 143
> Description: Could not create IO object for file
> /temp/itk-sample/copied/T1_MAP.hdr
> Tried to create one of the following:
> MetaImageIO
> You probably failed to set a file suffix, or
> set the suffix to an unsupported type.
>
>
>
> Program ended with exit code: 1
>
As stated in the example,
Every format desired to be supported by the reader
must be registered.
The ImageIO that reads Analyze files much be registered::
itk::AnalyzeImageIOFactory::RegisterOneFactor();
after including the appropriate header.
HTH,
Matt
More information about the Insight-users
mailing list