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 #include "clitkSegmentationUtils.h"
21 //--------------------------------------------------------------------
22 template<class ArgsInfoType>
23 clitk::MorphoMathGenericFilter<ArgsInfoType>::
24 MorphoMathGenericFilter():
25 ImageToImageGenericFilter<MorphoMathGenericFilter<ArgsInfoType> >("MorphMath")
28 cmdline_parser_clitkMorphoMath_init(&mArgsInfo);
29 InitializeImageType<2>();
30 InitializeImageType<3>();
31 InitializeImageType<4>();
33 //--------------------------------------------------------------------
36 //--------------------------------------------------------------------
37 template<class ArgsInfoType>
38 template<unsigned int Dim>
39 void clitk::MorphoMathGenericFilter<ArgsInfoType>::
42 ADD_DEFAULT_IMAGE_TYPES(Dim);
43 //ADD_IMAGE_TYPE(Dim, short); //
45 //--------------------------------------------------------------------
48 //--------------------------------------------------------------------
49 template<class ArgsInfoType>
50 void clitk::MorphoMathGenericFilter<ArgsInfoType>::
51 SetArgsInfo(const ArgsInfoType & a)
54 SetIOVerbose(mArgsInfo.verbose_flag);
55 if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes();
56 if (mArgsInfo.input_given) AddInputFilename(mArgsInfo.input_arg);
57 if (mArgsInfo.output_given) AddOutputFilename(mArgsInfo.output_arg);
59 //--------------------------------------------------------------------
62 //--------------------------------------------------------------------
63 template<class ArgsInfoType>
64 template<class FilterType>
65 void clitk::MorphoMathGenericFilter<ArgsInfoType>::
66 SetOptionsFromArgsInfoToFilter(FilterType * f)
68 f->SetVerboseFlag(mArgsInfo.verbose_flag);
69 f->SetExtendSupportFlag(mArgsInfo.extend_flag);
70 f->SetOperationType(mArgsInfo.type_arg);
71 f->SetBackgroundValue(mArgsInfo.bg_arg);
72 f->SetForegroundValue(mArgsInfo.fg_arg);
73 f->SetBoundaryToForegroundFlag(mArgsInfo.bound_flag);
74 if (mArgsInfo.radius_given && mArgsInfo.radiusInMM_given) {
75 clitkExceptionMacro("Please give --radius OR --radiusInMM, not both.");
78 if (mArgsInfo.radiusInMM_given) {
79 typename FilterType::PointType p;
80 if (mArgsInfo.radiusInMM_given) {
81 ConvertOptionMacro(mArgsInfo.radiusInMM, p, FilterType::ImageDimension, false);
86 typename FilterType::SizeType r;
87 if (mArgsInfo.radius_given) {
88 ConvertOptionMacro(mArgsInfo.radius, r, FilterType::ImageDimension, false);
94 //--------------------------------------------------------------------
95 // Update with the number of dimensions and the pixeltype
96 //--------------------------------------------------------------------
97 template<class ArgsInfoType>
98 template<class ImageType>
99 void clitk::MorphoMathGenericFilter<ArgsInfoType>::
100 UpdateWithInputImageType()
103 typename ImageType::Pointer input = this->template GetInput<ImageType>(0);
106 typedef clitk::MorphoMathFilter<ImageType> FilterType;
107 typename FilterType::Pointer filter = FilterType::New();
109 // Set the filter (needed for example for threaded monitoring)
110 this->SetFilterBase(filter);
112 // Set global Options
113 filter->SetInput(input);
114 SetOptionsFromArgsInfoToFilter<FilterType>(filter);
119 // Write/Save results
120 typename ImageType::Pointer output = filter->GetOutput();
121 this->template SetNextOutput<ImageType>(output);
123 //--------------------------------------------------------------------