1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://www.centreleonberard.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================*/
18 #ifndef clitkMedianImageGenericFilter_txx
19 #define clitkMedianImageGenericFilter_txx
21 /* =================================================
22 * @file clitkMedianImageGenericFilter.txx
23 * @author Bharath Navalapakkam <Bharath.Navalpakkam@creatis.insa-lyon.fr>
28 ===================================================*/
31 #include "itkMedianImageFilter.h"
37 //--------------------------------------------------------------------
38 template<class args_info_type>
39 MedianImageGenericFilter<args_info_type>::MedianImageGenericFilter():
40 ImageToImageGenericFilter<Self>("MedianImage")
42 InitializeImageType<2>();
43 InitializeImageType<3>();
44 InitializeImageType<4>();
46 //--------------------------------------------------------------------
49 //--------------------------------------------------------------------
50 template<class args_info_type>
51 template<unsigned int Dim>
52 void MedianImageGenericFilter<args_info_type>::InitializeImageType()
54 ADD_DEFAULT_IMAGE_TYPES(Dim);
56 //--------------------------------------------------------------------
59 //--------------------------------------------------------------------
60 template<class args_info_type>
61 void MedianImageGenericFilter<args_info_type>::SetArgsInfo(const args_info_type & a)
64 SetIOVerbose(mArgsInfo.verbose_flag);
66 if (mArgsInfo.input_given) {
67 SetInputFilename(mArgsInfo.input_arg);
69 if (mArgsInfo.output_given) {
70 SetOutputFilename(mArgsInfo.output_arg);
74 //--------------------------------------------------------------------
77 //--------------------------------------------------------------------
78 // Update with the number of dimensions and the pixeltype
79 //--------------------------------------------------------------------
80 template<class args_info_type>
81 template<class InputImageType>
83 MedianImageGenericFilter<args_info_type>::UpdateWithInputImageType()
86 typename InputImageType::Pointer input = this->template GetInput<InputImageType>(0);
88 typedef typename InputImageType::PixelType PixelType;
90 // typedef itk::Image<PixelType,InputImageType::ImageDimension> OutputImageType;
93 typedef itk::Image<PixelType, InputImageType::ImageDimension> OutputImageType;
94 typename InputImageType::SizeType indexRadius;
97 typedef itk::MedianImageFilter<InputImageType, OutputImageType> MedianImageFilterType;
98 typename MedianImageFilterType::Pointer thresholdFilter=MedianImageFilterType::New();
99 thresholdFilter->SetInput(input);
101 indexRadius[0]=mArgsInfo.radius_arg[0];
102 indexRadius[1]=mArgsInfo.radius_arg[1];
103 indexRadius[2]=mArgsInfo.radius_arg[2];
105 // indexRadius[0] = 1;
106 // indexRadius[1] = 1;
108 thresholdFilter->SetRadius( indexRadius );
110 typename OutputImageType::Pointer outputImage = thresholdFilter->GetOutput();
111 thresholdFilter->Update();
113 // Write/Save results
114 this->template SetNextOutput<OutputImageType>(outputImage);
117 //--------------------------------------------------------------------
122 #endif //#define clitkMedianImageGenericFilter_txx