Hi Robert,<br><br>thanks for your help. By following your instructions I received some errors:<br><br>warning C4346: 'itk::GradientRecursiveGaussianImageFilter<TImageType>::OutputImageType' : dependent name is not a type<br>
1> prefix with 'typename' to indicate a type<br>1> ...\myEdgeDetectionImageFilter.h(80) : see reference to class template instantiation 'itk::MelEdgeDetectionImageFilter<TImageType>' being compiled<br>
1>...\myEdgeDetectionImageFilter.h(61) : error C2923: 'itk::GradientToMagnitudeImageFilter' : 'itk::GradientRecursiveGaussianImageFilter<TImageType>::OutputImageType' is not a valid template type argument for parameter 'TInputImage'<br>
<br>therefore I was defining<br><br> <b> typedef typename itk::GradientRecursiveGaussianImageFilter<TImageType>::OutputImageType VectorImageType;<br></b><br>and replacing<br><br> <i> typedef GradientToMagnitudeImageFilter< GradientType::OutputImageType, TImageType > MagnitudeType;</i><br>
<div><br>with<br></div><br> <b>typedef GradientToMagnitudeImageFilter< VectorImageType, TImageType > MagnitudeType;<br></b><br>Now it is working!<br><br>Thanks a lot!<br><br>melanie<br><br><br><br><div class="gmail_quote">
2011/6/21 robert tamburo <span dir="ltr"><<a href="mailto:robert.tamburo@gmail.com">robert.tamburo@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Melanie,<div><br></div><div>GradientRecursiveGaussianImageFilter expects an output image type. You are giving it an output pixel type. You can 'cheat' and use the default template parameter by </div><div><br></div>
<div>Replacing<div class="im"><br><div> typedef GradientRecursiveGaussianImageFilter< TImageType, VectorPixelType > GradientType;<br> typedef GradientToMagnitudeImageFilter< VectorPixelType, TImageType > MagnitudeType;</div>
<div><br></div></div><div>by</div><div><br></div><div> typedef GradientRecursiveGaussianImageFilter< TImageType > GradientType;<br> typedef GradientToMagnitudeImageFilter< GradientType::OutputImageType, TImageType > MagnitudeType;</div>
<div><b><br></b></div><div>and consequently removing ComponentType and VectorPixelType.</div><div><br></div><div><b><br></b></div><div><div class="gmail_quote"><div><div></div><div class="h5">On Tue, Jun 21, 2011 at 10:51 AM, Melanie Uks <span dir="ltr"><<a href="mailto:meluks2010@googlemail.com" target="_blank">meluks2010@googlemail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div class="h5">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>
<br></div></div>_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br></div></div>
</blockquote></div><br>