]> Creatis software - clitk.git/blob - tools/clitkFooImageGenericFilter.txx
Add output dicom filename to clitkImage2Dicom
[clitk.git] / tools / clitkFooImageGenericFilter.txx
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to:
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
8
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.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18 #ifndef clitkFooImageGenericFilter_txx
19 #define clitkFooImageGenericFilter_txx
20
21 // itk include
22 #include "itkBinaryThresholdImageFilter.h"
23 #include "itkMaskImageFilter.h"
24 #include "itkMaskNegatedImageFilter.h"
25 #include <clitkCommon.h>
26
27 namespace clitk
28 {
29
30 //--------------------------------------------------------------------
31 template<class args_info_type>
32 FooImageGenericFilter<args_info_type>::FooImageGenericFilter():
33   ImageToImageGenericFilter<Self>("FooImage")
34 {
35   InitializeImageType<2>();
36   InitializeImageType<3>();
37   InitializeImageType<4>();
38 }
39 //--------------------------------------------------------------------
40
41
42 //--------------------------------------------------------------------
43 template<class args_info_type>
44 template<unsigned int Dim>
45 void FooImageGenericFilter<args_info_type>::InitializeImageType()
46 {
47   ADD_DEFAULT_IMAGE_TYPES(Dim);
48 }
49 //--------------------------------------------------------------------
50
51
52 //--------------------------------------------------------------------
53 template<class args_info_type>
54 void FooImageGenericFilter<args_info_type>::SetArgsInfo(const args_info_type & a)
55 {
56   mArgsInfo=a;
57   this->SetIOVerbose(mArgsInfo.verbose_flag);
58   if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes();
59
60   if (mArgsInfo.input_given) {
61     this->SetInputFilename(mArgsInfo.input_arg);
62   }
63   if (mArgsInfo.output_given) {
64     this->SetOutputFilename(mArgsInfo.output_arg);
65   }
66 }
67 //--------------------------------------------------------------------
68
69 //--------------------------------------------------------------------
70 // Update with the number of dimensions and the pixeltype
71 //--------------------------------------------------------------------
72 template<class args_info_type>
73 template<class InputImageType>
74 void
75 FooImageGenericFilter<args_info_type>::UpdateWithInputImageType()
76 {
77
78   // Reading input
79   typename InputImageType::Pointer input = this->template GetInput<InputImageType>(0);
80
81   // Main filter
82   typedef typename InputImageType::PixelType PixelType;
83   typedef itk::Image<char, InputImageType::ImageDimension> OutputImageType;
84
85   // Filter
86   typedef itk::BinaryThresholdImageFilter<InputImageType, OutputImageType> BinaryThresholdImageFilterType;
87   typename BinaryThresholdImageFilterType::Pointer thresholdFilter=BinaryThresholdImageFilterType::New();
88   thresholdFilter->SetInput(input);
89   // Set filter members
90
91   // Write/Save results
92   typename OutputImageType::Pointer outputImage = thresholdFilter->GetOutput();
93   this->template SetNextOutput<OutputImageType>(outputImage);
94 }
95 //--------------------------------------------------------------------
96
97
98 }//end clitk
99
100 #endif //#define clitkFooImageGenericFilter_txx