[Insight-users] Use of GradientRecursiveGaussianImageFilter in own CompositeFilter
Melanie Uks
meluks2010 at googlemail.com
Tue Jun 21 10:51:36 EDT 2011
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!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110621/8ea8f827/attachment.htm>
More information about the Insight-users
mailing list