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 this->SetIOVerbose(mArgsInfo.verbose_flag);
66 if (mArgsInfo.input_given) {
67 this->SetInputFilename(mArgsInfo.input_arg);
69 if (mArgsInfo.output_given) {
70 this->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::MedianImageFilter<InputImageType, InputImageType> MedianImageFilterType;
94 typename MedianImageFilterType::Pointer medianFilter=MedianImageFilterType::New();
95 typename MedianImageFilterType::InputSizeType radius;
97 medianFilter->SetInput(input);
99 if(mArgsInfo.radius_given) {
100 for (unsigned i = 0; i < InputImageType::ImageDimension; ++i)
101 radius[i]=mArgsInfo.radius_arg[i];
104 std::cout<<"radius median filter= "<<radius<<std::endl;
106 medianFilter->SetRadius( radius );
108 medianFilter->Update();
109 // Write/Save results
110 typename InputImageType::Pointer outputImage = medianFilter->GetOutput();
111 this->template SetNextOutput<InputImageType>(outputImage);
114 //--------------------------------------------------------------------
119 #endif //#define clitkMedianImageGenericFilter_txx