1 #ifndef clitkMedianImageGenericFilter_txx
2 #define clitkMedianImageGenericFilter_txx
4 /* =================================================
5 * @file clitkMedianImageGenericFilter.txx
6 * @author Bharath Navalapakkam <Bharath.Navalpakkam@creatis.insa-lyon.fr>
11 ===================================================*/
14 #include "itkMedianImageFilter.h"
20 //--------------------------------------------------------------------
21 template<class args_info_type>
22 MedianImageGenericFilter<args_info_type>::MedianImageGenericFilter():
23 ImageToImageGenericFilter<Self>("MedianImage")
25 InitializeImageType<2>();
26 InitializeImageType<3>();
27 InitializeImageType<4>();
29 //--------------------------------------------------------------------
32 //--------------------------------------------------------------------
33 template<class args_info_type>
34 template<unsigned int Dim>
35 void MedianImageGenericFilter<args_info_type>::InitializeImageType()
37 ADD_DEFAULT_IMAGE_TYPES(Dim);
39 //--------------------------------------------------------------------
42 //--------------------------------------------------------------------
43 template<class args_info_type>
44 void MedianImageGenericFilter<args_info_type>::SetArgsInfo(const args_info_type & a)
47 SetIOVerbose(mArgsInfo.verbose_flag);
49 if (mArgsInfo.input_given) {
50 SetInputFilename(mArgsInfo.input_arg);
52 if (mArgsInfo.output_given) {
53 SetOutputFilename(mArgsInfo.output_arg);
57 //--------------------------------------------------------------------
60 //--------------------------------------------------------------------
61 // Update with the number of dimensions and the pixeltype
62 //--------------------------------------------------------------------
63 template<class args_info_type>
64 template<class InputImageType>
66 MedianImageGenericFilter<args_info_type>::UpdateWithInputImageType()
69 typename InputImageType::Pointer input = this->template GetInput<InputImageType>(0);
71 typedef typename InputImageType::PixelType PixelType;
73 // typedef itk::Image<PixelType,InputImageType::ImageDimension> OutputImageType;
76 typedef itk::Image<PixelType, InputImageType::ImageDimension> OutputImageType;
77 typename InputImageType::SizeType indexRadius;
80 typedef itk::MedianImageFilter<InputImageType, OutputImageType> MedianImageFilterType;
81 typename MedianImageFilterType::Pointer thresholdFilter=MedianImageFilterType::New();
82 thresholdFilter->SetInput(input);
84 indexRadius[0]=mArgsInfo.radius_arg[0];
85 indexRadius[1]=mArgsInfo.radius_arg[1];
86 indexRadius[2]=mArgsInfo.radius_arg[2];
88 // indexRadius[0] = 1;
89 // indexRadius[1] = 1;
91 thresholdFilter->SetRadius( indexRadius );
93 typename OutputImageType::Pointer outputImage = thresholdFilter->GetOutput();
94 thresholdFilter->Update();
97 this->template SetNextOutput<OutputImageType>(outputImage);
100 //--------------------------------------------------------------------
105 #endif //#define clitkMedianImageGenericFilter_txx