Hi all,<br><br>I try to write my own filter starting with the CompositeFilterExample (Software Guide). Now I want to use the GradientRecursiveGaussianImageFilter and extract one component of the vectors with the VectorImageToImageAdaptor. I have some problems so far:<br>
<br>I get the following error:<br> <i>error C2664: 'itk::ImageAdaptor<TImage,TAccessor>::SetImage' : cannot convert parameter 1 from 'itk::Image<TPixel,VImageDimension> *' to 'itk::VectorImage<TPixel,VImageDimension> *'</i><br>
when I transfer the output of the gradient filter to the adapter: <span style="color: rgb(255, 0, 0);">m_ImageAdaptorFilter->SetImage(m_GradientFilter->GetOutput() );</span><br><br>If the adaptor is working how do I graft the output?<br>
<i> error C2039: 'GraftOutput' : is not a member of 'itk::VectorImageToImageAdaptor<TPixelType,Dimension>'<br></i><br>I hope someone can help me!<br><br>Thanks a lot!<br><br>Melanie<br><br><br><b><u>myEdgeDetectionImageFilter.h:</u></b><br>
<br>...<br>#include "itkGradientRecursiveGaussianImageFilter.h" <br>#include "itkVectorImageToImageAdaptor.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> ...<br> /** ImageDimension constant */<br> itkStaticConstMacro(ImageDimension, unsigned int,<br> TImageType::ImageDimension);<br>
<br> /** Define pixel types. */<br> typedef typename TImageType::PixelType PixelType;<br><br> /** Define image type**/<br> typedef typename itk::GradientRecursiveGaussianImageFilter<TImageType>::OutputImageType VectorImageType;<br>
<br> itkGetMacro( Sigma, PixelType);<br> itkSetMacro( Sigma, PixelType);<br><br>protected:<br><br> MelEdgeDetectionImageFilter();<br><br> typedef GradientRecursiveGaussianImageFilter< TImageType > GradientType;<br>
<b> </b>typedef VectorImageToImageAdaptor< VectorImageType, ImageDimension > ImageAdaptorType; <b style="color: rgb(255, 0, 0);"><span style="color: rgb(255, 0, 0);"> // </span>IS THIS </b><b style="color: rgb(255, 0, 0);">THE RIGHT DEFINITION?</b><br>
<br> void GenerateData();<br><br>private:<br><br> MelEdgeDetectionImageFilter(Self&); // intentionally not implemented<br> void operator=(const Self&); // intentionally not implemented<br><br> typename GradientType::Pointer m_GradientFilter;<br>
typename ImageAdaptorType::Pointer m_ImageAdaptorFilter;<br><br> PixelType m_Sigma;<br>};<br><br>} /* namespace itk */<br><br><b><u>myEdgeDetectionImageFilter.txx:</u></b><br>#include "myEdgeDetectionImageFilter.h"<br>
<br>namespace itk <br>{<br><br>template <class TImageType><br>MelEdgeDetectionImageFilter<TImageType><br>::MelEdgeDetectionImageFilter()<br>{<br> m_GradientFilter = GradientType::New();<br> m_ImageAdaptorFilter = ImageAdaptorType::New();<br>
<br> m_ImageAdaptorFilter->SetImage(m_GradientFilter->GetOutput() ); <b style="color: rgb(255, 0, 0);"><span style="color: rgb(255, 0, 0);"> // </span></b><b style="color: rgb(255, 0, 0);">THIS IS NOT POSSIBLE</b><br>
m_ImageAdaptorFilter->SetExtractComponentIndex(ImageDimension-1);<br><br> m_Sigma = 1;<br>}<br><br>template <class TImageType><br>void<br>MelEdgeDetectionImageFilter<TImageType>::<br>GenerateData()<br>{<br>
m_GradientFilter->SetInput( this->GetInput() );<br><br><b> m_ImageAdaptorFilter->GraftOutput( this->GetOutput() );<br> m_ImageAdaptorFilter->Update();<br> this->GraftOutput( m_ImageAdaptorFilter->GetOutput() );</b> <b style="color: rgb(255, 0, 0);"><span style="color: rgb(255, 0, 0);"> // </span></b><b style="color: rgb(255, 0, 0);">THIS IS NOT POSSIBLE BUT WHAT DO I USE INSTEAD?</b><br>
}<br><br>...<br>} /* end namespace itk */<br><br><br>