[Insight-users] Use of GradientRecursiveGaussianImageFilter in own CompositeFilter
Melanie Uks
meluks2010 at googlemail.com
Wed Jun 22 04:11:02 EDT 2011
Hi Robert,
thanks for your help. By following your instructions I received some errors:
warning C4346:
'itk::GradientRecursiveGaussianImageFilter<TImageType>::OutputImageType' :
dependent name is not a type
1> prefix with 'typename' to indicate a type
1> ...\myEdgeDetectionImageFilter.h(80) : see reference to class
template instantiation 'itk::MelEdgeDetectionImageFilter<TImageType>' being
compiled
1>...\myEdgeDetectionImageFilter.h(61) : error C2923:
'itk::GradientToMagnitudeImageFilter' :
'itk::GradientRecursiveGaussianImageFilter<TImageType>::OutputImageType' is
not a valid template type argument for parameter 'TInputImage'
therefore I was defining
* typedef typename
itk::GradientRecursiveGaussianImageFilter<TImageType>::OutputImageType
VectorImageType;
*
and replacing
* typedef GradientToMagnitudeImageFilter< GradientType::OutputImageType,
TImageType > MagnitudeType;*
with
*typedef GradientToMagnitudeImageFilter< VectorImageType, TImageType >
MagnitudeType;
*
Now it is working!
Thanks a lot!
melanie
2011/6/21 robert tamburo <robert.tamburo at gmail.com>
> Hi Melanie,
>
> GradientRecursiveGaussianImageFilter expects an output image type. You are
> giving it an output pixel type. You can 'cheat' and use the default template
> parameter by
>
> Replacing
>
> typedef GradientRecursiveGaussianImageFilter< TImageType, VectorPixelType
> > GradientType;
> typedef GradientToMagnitudeImageFilter< VectorPixelType, TImageType >
> MagnitudeType;
>
> by
>
> typedef GradientRecursiveGaussianImageFilter< TImageType >
> GradientType;
> typedef GradientToMagnitudeImageFilter< GradientType::OutputImageType,
> TImageType > MagnitudeType;
> *
> *
> and consequently removing ComponentType and VectorPixelType.
>
> *
> *
> On Tue, Jun 21, 2011 at 10:51 AM, Melanie Uks <meluks2010 at googlemail.com>wrote:
>
>> Hi all,
>>
>> 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.
>> Maybe one of you finds the problem. I highlight the code I changed:
>>
>>
>> ------------------------------------------------------------------------------
>>
>> #ifndef __myEdgeDetectionImageFilter_h
>> #define __myEdgeDetectionImageFilter_h
>>
>> #include "itkImageToImageFilter.h"
>> *#include "itkGradientRecursiveGaussianImageFilter.h"
>> #include "itkGradientToMagnitudeImageFilter.h" *
>> #include "itkThresholdImageFilter.h"
>> #include "itkRescaleIntensityImageFilter.h"
>>
>> *#include "itkCovariantVector.h"*
>> #include "itkNumericTraits.h"
>>
>>
>> namespace itk {
>>
>> template <class TImageType>
>> class ITK_EXPORT MelEdgeDetectionImageFilter :
>> public ImageToImageFilter<TImageType, TImageType>
>> {
>> public:
>>
>> typedef MelEdgeDetectionImageFilter Self;
>> typedef ImageToImageFilter<TImageType,TImageType> Superclass;
>> typedef SmartPointer<Self> Pointer;
>> typedef SmartPointer<const Self> ConstPointer;
>>
>> /** Method for creation through object factory */
>> itkNewMacro(Self);
>>
>> /** Run-time type information */
>> itkTypeMacro(MelEdgeDetectionImageFilter, ImageToImageFilter);
>>
>> /** Display */
>> void PrintSelf( std::ostream& os, Indent indent ) const;
>>
>> /** ImageDimension constant */
>> itkStaticConstMacro(ImageDimension, unsigned int,
>> TImageType::ImageDimension);
>>
>> /** Define pixel types. */
>> typedef typename TImageType::PixelType PixelType;
>> * typedef typename float ComponentType;
>> typedef typename itk::CovariantVector< ComponentType,
>> ImageDimension > VectorPixelType;*
>>
>>
>> itkGetMacro( Threshold, PixelType);
>> itkSetMacro( Threshold, PixelType);
>>
>> * itkGetMacro( Sigma, PixelType);
>> itkSetMacro( Sigma, PixelType);*
>>
>> protected:
>>
>> MelEdgeDetectionImageFilter();
>>
>> protected:
>>
>> typedef ThresholdImageFilter< TImageType > ThresholdType;
>> * typedef GradientRecursiveGaussianImageFilter< TImageType,
>> VectorPixelType > GradientType;
>> typedef GradientToMagnitudeImageFilter< VectorPixelType, TImageType >
>> MagnitudeType;*
>> typedef RescaleIntensityImageFilter< TImageType, TImageType >
>> RescalerType;
>>
>> void GenerateData();
>>
>> private:
>>
>> MelEdgeDetectionImageFilter(Self&); // intentionally not implemented
>> void operator=(const Self&); // intentionally not implemented
>>
>>
>> * typename GradientType::Pointer m_GradientFilter;
>> typename MagnitudeType::Pointer m_MagnitudeFilter;*
>> typename ThresholdType::Pointer m_ThresholdFilter;
>> typename RescalerType::Pointer m_RescaleFilter;
>>
>> PixelType m_Threshold;
>>
>> * PixelType m_Sigma;*
>> };
>>
>> } /* namespace itk */
>>
>> #ifndef ITK_MANUAL_INSTANTIATION
>> #include "myEdgeDetectionImageFilter.txx"
>> #endif
>>
>> #endif
>>
>>
>>
>> ------------------------------------------------------------------------------
>>
>> #ifndef __myEdgeDetectionImageFilter_txx
>> #define __myEdgeDetectionImageFilter_txx
>>
>> #include "myEdgeDetectionImageFilter.h"
>>
>> namespace itk
>> {
>>
>> template <class TImageType>
>> MelEdgeDetectionImageFilter<TImageType>
>> ::MelEdgeDetectionImageFilter()
>> {
>> *m_GradientFilter = GradientType::New();
>> m_MagnitudeFilter = MagnitudeType::New();*
>> m_ThresholdFilter = ThresholdType::New();
>> m_RescaleFilter = RescalerType::New();
>>
>> * m_MagnitudeFilter->SetInput(m_GradientFilter->GetOutput() );
>> m_ThresholdFilter->SetInput( m_MagnitudeFilter->GetOutput() );*
>> m_RescaleFilter->SetInput( m_ThresholdFilter->GetOutput() );
>>
>> m_Threshold = 1;
>> * m_Sigma = 1;*
>>
>> m_RescaleFilter->SetOutputMinimum(*NumericTraits<PixelType>::Zero*);
>> m_RescaleFilter->SetOutputMaximum(NumericTraits<PixelType>::max());
>> }
>>
>> template <class TImageType>
>> void
>> MelEdgeDetectionImageFilter<TImageType>::
>> GenerateData()
>> {
>> * m_GradientFilter->SetInput( this->GetInput() );*
>>
>> m_ThresholdFilter->ThresholdBelow( this->m_Threshold );
>>
>> m_RescaleFilter->GraftOutput( this->GetOutput() );
>> m_RescaleFilter->Update();
>> this->GraftOutput( m_RescaleFilter->GetOutput() );
>> }
>>
>> template <class TImageType>
>> void
>> MelEdgeDetectionImageFilter<TImageType>::
>> PrintSelf( std::ostream& os, Indent indent ) const
>> {
>> Superclass::PrintSelf(os,indent);
>>
>> os
>> << indent << "Threshold:" << this->m_Threshold
>> << std::endl;
>> * os
>> << indent << "Sigma:" << this->m_Sigma
>> << std::endl;*
>> }
>>
>> } /* end namespace itk */
>>
>> #endif
>>
>>
>> Thanks a lot for your help!
>>
>>
>> _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> http://www.kitware.com/products/protraining.html
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110622/d4a30312/attachment.htm>
More information about the Insight-users
mailing list