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://oncora1.lyon.fnclcc.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 clitkUnsharpMaskGenericFilter_txx
19 #define clitkUnsharpMaskGenericFilter_txx
21 /* =================================================
22 * @file clitkUnsharpMaskGenericFilter.txx
23 * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
28 ===================================================*/
31 #include "itkRecursiveGaussianImageFilter.h"
32 #include "itkSubtractImageFilter.h"
33 #include <clitkCommon.h>
38 //--------------------------------------------------------------------
39 template<class args_info_type>
40 UnsharpMaskGenericFilter<args_info_type>::UnsharpMaskGenericFilter():
41 ImageToImageGenericFilter<Self>("UnsharpMask") {
42 InitializeImageType<2>();
43 InitializeImageType<3>();
44 //InitializeImageType<4>();
46 //--------------------------------------------------------------------
49 //--------------------------------------------------------------------
50 template<class args_info_type>
51 template<unsigned int Dim>
52 void UnsharpMaskGenericFilter<args_info_type>::InitializeImageType() {
53 ADD_DEFAULT_IMAGE_TYPES(Dim);
55 //--------------------------------------------------------------------
58 //--------------------------------------------------------------------
59 template<class args_info_type>
60 void UnsharpMaskGenericFilter<args_info_type>::SetArgsInfo(const args_info_type & a) {
62 SetIOVerbose(mArgsInfo.verbose_flag);
63 if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes();
65 if (mArgsInfo.input_given) {
66 SetInputFilename(mArgsInfo.input_arg);
68 if (mArgsInfo.output_given) {
69 SetOutputFilename(mArgsInfo.output_arg);
72 //--------------------------------------------------------------------
74 //--------------------------------------------------------------------
75 // Update with the number of dimensions and the pixeltype
76 //--------------------------------------------------------------------
77 template<class args_info_type>
78 template<class InputImageType>
80 UnsharpMaskGenericFilter<args_info_type>::UpdateWithInputImageType()
84 typename InputImageType::Pointer input = this->template GetInput<InputImageType>(0);
87 typedef typename InputImageType::PixelType PixelType;
88 typedef itk::Image<float, InputImageType::ImageDimension> OutputImageType;
91 typedef itk::RecursiveGaussianImageFilter<InputImageType, OutputImageType> RecursiveGaussianImageFilterType;
92 typename RecursiveGaussianImageFilterType::Pointer gaussianFilter=RecursiveGaussianImageFilterType::New();
93 gaussianFilter->SetInput(input);
94 gaussianFilter->SetSigma(mArgsInfo.sigma_arg);
96 typedef itk::SubtractImageFilter<InputImageType, OutputImageType, OutputImageType> SubtractFilterType;
97 typename SubtractFilterType::Pointer subtractFilter = SubtractFilterType::New();
98 subtractFilter->SetInput1(input);
99 subtractFilter->SetInput2(gaussianFilter->GetOutput());
100 subtractFilter->Update();
102 this->template SetNextOutput<OutputImageType>(subtractFilter->GetOutput());
104 //--------------------------------------------------------------------
109 #endif //#define clitkUnsharpMaskGenericFilter_txx