[Insight-users] filter 4D to 3D, itk exception "itk::ImageBase::CopyInformation() cannot cast"

yoyi1970 at yahoo.es yoyi1970 at yahoo.es
Wed Jun 20 12:36:26 EDT 2012


I'm implementing a filter that take 4 4D images as input and produce a 3D image as output. While executing I get the following exception:

 terminate called after throwing an instance of 'itk::ExceptionObject'
  what():  /usr/local/ITK-4.2/include/ITK-4.2/itkImageBase.hxx:336:
itk::ERROR: Image(0x993f480): itk::ImageBase::CopyInformation() cannot cast PKN3itk10DataObjectE to PKN3itk9ImageBaseILj3EEE
Aborted


this is the declaration of the class

typedef float PCPixelType;
typedef Image< PCPixelType, 4 > PhaseContrastImage;
typedef Image< PCPixelType, 3 > PhaseContrast3DImage;



class PhaseContrastTimeAveragedImageFilter : public ImageToImageFilter< PhaseContrastImage, PhaseContrast3DImage >
{
public:
  /** Standard class typedefs. */
  typedef PhaseContrastTimeAveragedImageFilter             Self;
  typedef ImageToImageFilter< PhaseContrastImage, PhaseContrast3DImage > Superclass;
  typedef SmartPointer< Self >        Pointer;
  /** Method for creation through the object factory. */
  itkNewMacro(Self);
 
  /** Run-time type information (and related methods). */
  itkTypeMacro(PhaseContrastTimeAveragedImageFilter, ImageToImageFilter);
 
  /** The 4D magnitude image.*/
  void SetMagnitudeImage(const PhaseContrastImage* image);
 
  /** The 4D X component of the phase image.*/
  void SetPhaseXImage(const PhaseContrastImage* image);

  /** The 4D Y component of the phase image.*/
  void SetPhaseYImage(const PhaseContrastImage* image);

  /** The 4D Z component of the phase image.*/
  void SetPhaseZImage(const PhaseContrastImage* image);

  
  itkGetConstMacro(NoiseMaskThreshold, float);
  void SetNoiseMaskThreshold( float threshold );
  
protected:
  PhaseContrastTimeAveragedImageFilter()
 {
    this->SetNumberOfRequiredInputs(4);
    this->m_NoiseMaskThreshold = 0.1;
    this->m_NoiseMaskThresholdValue = 0.0;
    this->m_MaximumMagnitude = 0.0;
    this->m_MinimumMagnitude = 0.0;
  }

  ~PhaseContrastTimeAveragedImageFilter() {}

  virtual void BeforeThreadedGenerateData();
 
  /** Does the real work. */
  virtual void ThreadedGenerateData(const Superclass::OutputImageRegionType& outputRegionForThread, int threadId);
  
private:
  PhaseContrastTimeAveragedImageFilter(const Self &); //purposely not implemented
  void operator=(const Self &);  //purposely not implemented

  float m_NoiseMaskThreshold;
  float m_NoiseMaskThresholdValue;
  float m_MaximumMagnitude;
  float m_MinimumMagnitude;
};


Any suggestion of how to find out or where to look for in order to solve the problem raised by the exception?

best regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120620/6cad4ab8/attachment.htm>


More information about the Insight-users mailing list