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 ===========================================================================**/
19 #ifndef CLITKEXTRACTBONESSGENERICFILTER_TXX
20 #define CLITKEXTRACTBONESSGENERICFILTER_TXX
22 #include "clitkImageCommon.h"
24 //--------------------------------------------------------------------
25 template<class ArgsInfoType>
26 clitk::ExtractBonesGenericFilter<ArgsInfoType>::ExtractBonesGenericFilter():
27 ImageToImageGenericFilter<Self>("ExtractBones")
30 cmdline_parser_clitkExtractBones_init(&mArgsInfo);
31 InitializeImageType<3>();
33 //--------------------------------------------------------------------
36 //--------------------------------------------------------------------
37 template<class ArgsInfoType>
38 template<unsigned int Dim>
39 void clitk::ExtractBonesGenericFilter<ArgsInfoType>::InitializeImageType()
41 ADD_IMAGE_TYPE(Dim, short);
42 // ADD_IMAGE_TYPE(Dim, int);
43 ADD_IMAGE_TYPE(Dim, float);
45 //--------------------------------------------------------------------
48 //--------------------------------------------------------------------
49 template<class ArgsInfoType>
50 void clitk::ExtractBonesGenericFilter<ArgsInfoType>::SetArgsInfo(const ArgsInfoType & a)
53 SetIOVerbose(mArgsInfo.verbose_flag);
54 if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes();
55 if (mArgsInfo.input_given) AddInputFilename(mArgsInfo.input_arg);
56 if (mArgsInfo.output_given) AddOutputFilename(mArgsInfo.output_arg);
58 //--------------------------------------------------------------------
61 //--------------------------------------------------------------------
62 template<class ArgsInfoType>
63 template<class FilterType>
64 void clitk::ExtractBonesGenericFilter<ArgsInfoType>::
65 SetOptionsFromArgsInfoToFilter(FilterType * f)
67 f->SetVerboseOptionFlag(mArgsInfo.verboseOption_flag);
68 f->SetVerboseStepFlag(mArgsInfo.verboseStep_flag);
69 f->SetWriteStepFlag(mArgsInfo.writeStep_flag);
70 f->SetVerboseWarningFlag(!mArgsInfo.verboseWarningOff_flag);
71 f->SetVerboseMemoryFlag(mArgsInfo.verboseMemory_flag);
73 if (mArgsInfo.afdb_given)
74 f->SetAFDBFilename(mArgsInfo.afdb_arg);
76 f->SetOutputBonesFilename(mArgsInfo.output_arg);
78 f->SetInitialSmoothing(mArgsInfo.smooth_flag);
79 f->SetSmoothingConductanceParameter(mArgsInfo.cond_arg);
80 f->SetSmoothingNumberOfIterations(mArgsInfo.iter_arg);
81 f->SetSmoothingTimeStep(mArgsInfo.time_arg);
82 f->SetSmoothingUseImageSpacing(mArgsInfo.spacing_flag);
84 f->SetMinimalComponentSize(mArgsInfo.minSize_arg);
85 f->SetUpperThreshold1(mArgsInfo.upper1_arg);
86 f->SetLowerThreshold1(mArgsInfo.lower1_arg);
87 f->SetFullConnectivity(mArgsInfo.full_flag);
89 f->SetUpperThreshold2(mArgsInfo.upper2_arg);
90 f->SetLowerThreshold2(mArgsInfo.lower2_arg);
92 typename FilterType::InputImageSizeType s;
93 if (mArgsInfo.radius2_given) {
94 ConvertOptionMacro(mArgsInfo.radius2, s, 3, false);
98 f->SetSampleRate2(mArgsInfo.sampleRate2_arg);
99 f->SetAutoCrop(!mArgsInfo.noAutoCrop_flag);
100 f->SetFillHoles(!mArgsInfo.doNotFillHoles_flag);
102 //--------------------------------------------------------------------
105 //--------------------------------------------------------------------
106 // Update with the number of dimensions and the pixeltype
107 //--------------------------------------------------------------------
108 template<class ArgsInfoType>
109 template<class ImageType>
110 void clitk::ExtractBonesGenericFilter<ArgsInfoType>::UpdateWithInputImageType()
112 // Mask & output image type
113 typedef itk::Image<uchar, ImageType::ImageDimension> MaskImageType;
116 typename ImageType::Pointer input = this->template GetInput<ImageType>(0);
119 typedef clitk::ExtractBonesFilter<ImageType> FilterType;
120 typename FilterType::Pointer filter = FilterType::New();
122 // Set global Options
123 filter->SetInput(input);
124 SetOptionsFromArgsInfoToFilter<FilterType>(filter);
129 // Write/Save results
130 typename MaskImageType::Pointer output = filter->GetOutput();
131 this->template SetNextOutput<MaskImageType>(output);
133 //--------------------------------------------------------------------
135 #endif //#define CLITKEXTRACTBONESSGENERICFILTER_TXX