]> Creatis software - clitk.git/blob - segmentation/clitkExtractMediastinumGenericFilter.txx
679fb36cc22deb0f372b21fe5966bbc414b3cc7f
[clitk.git] / segmentation / clitkExtractMediastinumGenericFilter.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
19 #ifndef CLITKEXTRACTMEDIASTINUMSGENERICFILTER_TXX
20 #define CLITKEXTRACTMEDIASTINUMSGENERICFILTER_TXX
21
22 #include "clitkImageCommon.h"
23   
24 //--------------------------------------------------------------------
25 template<class ArgsInfoType>
26 clitk::ExtractMediastinumGenericFilter<ArgsInfoType>::
27 ExtractMediastinumGenericFilter():
28   ImageToImageGenericFilter<Self>("ExtractMediastinum") 
29 {
30   // Default values
31   cmdline_parser_clitkExtractMediastinum_init(&mArgsInfo);
32   InitializeImageType<3>();
33 }
34 //--------------------------------------------------------------------
35
36
37 //--------------------------------------------------------------------
38 template<class ArgsInfoType>
39 template<unsigned int Dim>
40 void 
41 clitk::ExtractMediastinumGenericFilter<ArgsInfoType>::
42 InitializeImageType() 
43 {  
44   ADD_IMAGE_TYPE(Dim, short);
45 }
46 //--------------------------------------------------------------------
47   
48
49 //--------------------------------------------------------------------
50 template<class ArgsInfoType>
51 void 
52 clitk::ExtractMediastinumGenericFilter<ArgsInfoType>::
53 SetArgsInfo(const ArgsInfoType & a) 
54 {
55   mArgsInfo=a;
56   SetIOVerbose(mArgsInfo.verbose_flag);
57   if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes();
58   if (mArgsInfo.input_given) AddInputFilename(mArgsInfo.input_arg);
59   if (mArgsInfo.output_given)  AddOutputFilename(mArgsInfo.output_arg);
60 }
61 //--------------------------------------------------------------------
62
63
64 //--------------------------------------------------------------------
65 template<class ArgsInfoType>
66 template<class FilterType>
67 void 
68 clitk::ExtractMediastinumGenericFilter<ArgsInfoType>::
69 SetOptionsFromArgsInfoToFilter(FilterType * f)
70 {
71   f->SetVerboseOptionFlag(mArgsInfo.verbose_flag);
72   f->SetVerboseStepFlag(mArgsInfo.verboseStep_flag);
73   f->SetWriteStepFlag(mArgsInfo.writeStep_flag);
74   f->SetAFDBFilename(mArgsInfo.afdb_arg);  
75   f->SetOutputMediastinumFilename(mArgsInfo.output_arg);
76   f->SetVerboseMemoryFlag(mArgsInfo.verboseMemory_flag);
77
78   f->SetDistanceMaxToAnteriorPartOfTheVertebralBody(mArgsInfo.maxAntSpine_arg);
79   f->SetUseBones(mArgsInfo.useBones_flag);
80
81   // Set RelativePositionList filenames
82   for(uint i=0; i<mArgsInfo.relpos_given; i++) {
83     f->AddRelativePositionListFilename(mArgsInfo.relpos_arg[i]);
84   }
85 }
86 //--------------------------------------------------------------------
87
88
89 //--------------------------------------------------------------------
90 // Update with the number of dimensions and the pixeltype
91 //--------------------------------------------------------------------
92 template<class ArgsInfoType>
93 template<class ImageType>
94 void clitk::ExtractMediastinumGenericFilter<ArgsInfoType>::UpdateWithInputImageType() 
95
96   // Reading input
97   typename ImageType::Pointer input = this->template GetInput<ImageType>(0);
98
99   // Create filter
100   typedef clitk::ExtractMediastinumFilter<ImageType> FilterType;
101   typename FilterType::Pointer filter = FilterType::New();
102     
103   // Set global Options 
104   filter->SetInput(input);
105   SetOptionsFromArgsInfoToFilter<FilterType>(filter);
106
107   // Go !
108   filter->Update();
109
110   // Write/Save results
111   typename FilterType::MaskImageType::Pointer output = filter->GetOutput();
112   this->template SetNextOutput<typename FilterType::MaskImageType>(output); 
113 }
114 //--------------------------------------------------------------------
115
116 #endif //#define CLITKEXTRACTMEDIASTINUMSGENERICFILTER_TXX