[Insight-users] Problems with fixedReader->Update();

motes motes mort.motes at gmail.com
Tue Jul 21 16:54:44 EDT 2009


The error has moved on to when I try to create the deformation field in the
BSplineWarping1.cxx example (modified slightly below)


  typedef itk::Point<float,
ImageDimension>                                               PointType;
  typedef itk::Vector<float,
ImageDimension>                                              VectorType;
  typedef itk::Image<VectorType,
ImageDimension>
DeformationFieldType;
  typedef
TransformType::SpacingType
SpacingType;
  typedef
TransformType::ParametersType
ParametersType;
  typedef
TransformType::OriginType
OriginType;
  typedef
itk::ImageRegionIterator<DeformationFieldType>
FieldIterator;
  typedef
itk::ImageFileWriter<DeformationFieldType>
FieldWriterType;

  DeformationFieldType::Pointer field = DeformationFieldType::New();
  FieldWriterType::Pointer fieldWriter = FieldWriterType::New();

...
...

std::string in_field = "c:\deformed_field.png";

    fieldWriter->SetInput( field );

        if( !in_field.empty() )
    {
      fieldWriter->SetFileName(in_field);
      try
      {
        fieldWriter->Update();
      }
      catch( itk::ExceptionObject & excp )
      {
        std::cerr << "Exception thrown " << std::endl;
        std::cerr << excp << std::endl;
        return EXIT_FAILURE;
      }
    }


Should the deformation field have a certain type?



2009/7/21 motes motes <mort.motes at gmail.com>

> Ok in the followup its recommended to change the type of PixelType to:
>
> typedef unsigned char  PixelType;
>
> or
>
> typedef unsigned short   PixelType;
>
>
> But I already declared it as :
>
> typedef unsigned char  PixelType;
>
> and I have also tried:
>
> typedef unsigned short   PixelType;
>
> but I still get the same error, any ideas?
>
>
>
>
> 2009/7/21 Ramón Casero Cañas <ramon.casero at comlab.ox.ac.uk>
>
> motes motes wrote:
>>
>>>
>>> But the call:
>>>      fixedReader->Update();
>>>
>>> throws the exception:
>>>
>>> Exception thrown
>>>
>>> itk::ExceptionObject (00CAE438)
>>> Location: "void __thiscall itk::PNGImageIO::WriteSlice(const class
>>> std::basic_string<char,struct std::char_traits<c
>>> har>,class std::allocator<char> > &,const void *)"
>>> File: ..\..\..\Code\IO\itkPNGImageIO.cxx
>>> Line: 473
>>> Description: PNG supports unsigned char and unsigned short
>>>
>>>
>>> I have tried removing the update() call but then I get an error further
>>> down
>>> the code. It seems that the error is related to the PNG format of the
>>> file,
>>> any ideas?
>>>
>>
>> Hi motes,
>>
>> A quick search in google of the error, i.e. search for
>>
>> "Description: PNG supports unsigned char and unsigned short"
>>
>> shows that this problem has been addressed in a previous thread of this
>> list
>>
>> http://www.itk.org/pipermail/insight-users/2006-September/019320.html
>>
>> Cheers,
>>
>> Ramon.
>>
>> --
>> Ramón Casero Cañas, DPhil
>>
>> Computational Biology, Computing Laboratory
>> University of Oxford
>> Wolfson Building, Parks Rd
>> Oxford OX1 3QD
>>
>> tlf     +44 (0) 1865 610807
>> web     http://web.comlab.ox.ac.uk/people/Ramon.CaseroCanas
>> photos  http://www.flickr.com/photos/rcasero/
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090721/4b1e7d85/attachment-0001.htm>


More information about the Insight-users mailing list