Hi all,<br><br>I try to write my own filter starting with the CompositeFilterExample (Software Guide). I could run the example filter and then I wanted to modify the filter by removing the GaussianFilter and adding a GradientRecursiveGaussianImageFilter and a GradientToMagnitudeImageFilter. I was not able to run the code again. I guess I made a mistake with the component vector type. The errors (more than 50 :-( ) do not help to solve the problem.<br>
Maybe one of you finds the problem. I highlight the code I changed:<br><br>------------------------------------------------------------------------------<br><br>#ifndef __myEdgeDetectionImageFilter_h<br>#define __myEdgeDetectionImageFilter_h<br>
<br>#include "itkImageToImageFilter.h"<br><b>#include "itkGradientRecursiveGaussianImageFilter.h" <br>#include "itkGradientToMagnitudeImageFilter.h" </b> <br>#include "itkThresholdImageFilter.h"<br>
#include "itkRescaleIntensityImageFilter.h"<br><br><b>#include "itkCovariantVector.h"</b><br>#include "itkNumericTraits.h"<br><br><br>namespace itk {<br><br>template <class TImageType><br>
class ITK_EXPORT MelEdgeDetectionImageFilter :<br> public ImageToImageFilter<TImageType, TImageType><br>{<br>public:<br><br> typedef MelEdgeDetectionImageFilter Self;<br> typedef ImageToImageFilter<TImageType,TImageType> Superclass;<br>
typedef SmartPointer<Self> Pointer;<br> typedef SmartPointer<const Self> ConstPointer;<br><br> /** Method for creation through object factory */<br> itkNewMacro(Self);<br>
<br> /** Run-time type information */<br> itkTypeMacro(MelEdgeDetectionImageFilter, ImageToImageFilter);<br><br> /** Display */<br> void PrintSelf( std::ostream& os, Indent indent ) const;<br><br> /** ImageDimension constant */<br>
itkStaticConstMacro(ImageDimension, unsigned int,<br> TImageType::ImageDimension);<br><br> /** Define pixel types. */<br> typedef typename TImageType::PixelType PixelType;<br> <b> typedef typename float ComponentType;<br>
typedef typename itk::CovariantVector< ComponentType, <br> ImageDimension > VectorPixelType;</b><br> <br><br> itkGetMacro( Threshold, PixelType);<br> itkSetMacro( Threshold, PixelType);<br>
<br><b> itkGetMacro( Sigma, PixelType);<br> itkSetMacro( Sigma, PixelType);</b><br><br>protected:<br><br> MelEdgeDetectionImageFilter();<br><br>protected:<br><br> typedef ThresholdImageFilter< TImageType > ThresholdType;<br>
<b> typedef GradientRecursiveGaussianImageFilter< TImageType, VectorPixelType > GradientType;<br> typedef GradientToMagnitudeImageFilter< VectorPixelType, TImageType > MagnitudeType;</b><br> typedef RescaleIntensityImageFilter< TImageType, TImageType > RescalerType;<br>
<br> void GenerateData();<br><br>private:<br><br> MelEdgeDetectionImageFilter(Self&); // intentionally not implemented<br> void operator=(const Self&); // intentionally not implemented<br><br><br><b> typename GradientType::Pointer m_GradientFilter;<br>
typename MagnitudeType::Pointer m_MagnitudeFilter;</b><br> typename ThresholdType::Pointer m_ThresholdFilter;<br> typename RescalerType::Pointer m_RescaleFilter;<br><br> PixelType m_Threshold;<br><br> <b> PixelType m_Sigma;</b><br>
};<br><br>} /* namespace itk */<br><br>#ifndef ITK_MANUAL_INSTANTIATION<br>#include "myEdgeDetectionImageFilter.txx"<br>#endif<br><br>#endif<br><br><br>
------------------------------------------------------------------------------<br><br>#ifndef __myEdgeDetectionImageFilter_txx<br>#define __myEdgeDetectionImageFilter_txx<br><br>#include "myEdgeDetectionImageFilter.h"<br>
<br>namespace itk <br>{<br><br>template <class TImageType><br>MelEdgeDetectionImageFilter<TImageType><br>::MelEdgeDetectionImageFilter()<br>{<br> <b>m_GradientFilter = GradientType::New();<br> m_MagnitudeFilter = MagnitudeType::New();</b><br>
m_ThresholdFilter = ThresholdType::New();<br> m_RescaleFilter = RescalerType::New();<br><br> <b> m_MagnitudeFilter->SetInput(m_GradientFilter->GetOutput() );<br> m_ThresholdFilter->SetInput( m_MagnitudeFilter->GetOutput() );</b><br>
m_RescaleFilter->SetInput( m_ThresholdFilter->GetOutput() );<br><br> m_Threshold = 1;<br> <b> m_Sigma = 1;</b><br><br> m_RescaleFilter->SetOutputMinimum(<b>NumericTraits<PixelType>::Zero</b>);<br> m_RescaleFilter->SetOutputMaximum(NumericTraits<PixelType>::max());<br>
}<br><br>template <class TImageType><br>void<br>MelEdgeDetectionImageFilter<TImageType>::<br>GenerateData()<br>{<br> <b> m_GradientFilter->SetInput( this->GetInput() );</b><br><br> m_ThresholdFilter->ThresholdBelow( this->m_Threshold );<br>
<br> m_RescaleFilter->GraftOutput( this->GetOutput() );<br> m_RescaleFilter->Update();<br> this->GraftOutput( m_RescaleFilter->GetOutput() );<br>}<br><br>template <class TImageType><br>void<br>MelEdgeDetectionImageFilter<TImageType>::<br>
PrintSelf( std::ostream& os, Indent indent ) const<br>{<br> Superclass::PrintSelf(os,indent);<br><br> os<br> << indent << "Threshold:" << this->m_Threshold<br> << std::endl;<br>
<b> os<br> << indent << "Sigma:" << this->m_Sigma<br> << std::endl;</b><br>}<br><br>} /* end namespace itk */<br><br>#endif<br><br><br>Thanks a lot for your help!<br><br>