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") {
24 InitializeImageType<2>();
25 InitializeImageType<3>();
26 InitializeImageType<4>();
28 //--------------------------------------------------------------------
31 //--------------------------------------------------------------------
32 template<class args_info_type>
33 template<unsigned int Dim>
34 void MedianImageGenericFilter<args_info_type>::InitializeImageType() {
35 ADD_DEFAULT_IMAGE_TYPES(Dim);
37 //--------------------------------------------------------------------
40 //--------------------------------------------------------------------
41 template<class args_info_type>
42 void MedianImageGenericFilter<args_info_type>::SetArgsInfo(const args_info_type & a) {
44 SetIOVerbose(mArgsInfo.verbose_flag);
46 if (mArgsInfo.input_given) {
47 SetInputFilename(mArgsInfo.input_arg);
49 if (mArgsInfo.output_given) {
50 SetOutputFilename(mArgsInfo.output_arg);
54 //--------------------------------------------------------------------
57 //--------------------------------------------------------------------
58 // Update with the number of dimensions and the pixeltype
59 //--------------------------------------------------------------------
60 template<class args_info_type>
61 template<class InputImageType>
63 MedianImageGenericFilter<args_info_type>::UpdateWithInputImageType()
66 typename InputImageType::Pointer input = this->template GetInput<InputImageType>(0);
68 typedef typename InputImageType::PixelType PixelType;
70 // typedef itk::Image<PixelType,InputImageType::ImageDimension> OutputImageType;
73 typedef itk::Image<PixelType, InputImageType::ImageDimension> OutputImageType;
74 typename InputImageType::SizeType indexRadius;
77 typedef itk::MedianImageFilter<InputImageType, OutputImageType> MedianImageFilterType;
78 typename MedianImageFilterType::Pointer thresholdFilter=MedianImageFilterType::New();
79 thresholdFilter->SetInput(input);
81 indexRadius[0]=mArgsInfo.radius_arg[0];
82 indexRadius[1]=mArgsInfo.radius_arg[1];
83 indexRadius[2]=mArgsInfo.radius_arg[2];
85 // indexRadius[0] = 1;
86 // indexRadius[1] = 1;
88 thresholdFilter->SetRadius( indexRadius );
90 typename OutputImageType::Pointer outputImage = thresholdFilter->GetOutput();
91 thresholdFilter->Update();
94 this->template SetNextOutput<OutputImageType>(outputImage);
97 //--------------------------------------------------------------------
102 #endif //#define clitkMedianImageGenericFilter_txx