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 "clitkImageCommon.h"
21 //--------------------------------------------------------------------
22 template<class ArgsInfoType>
23 clitk::RelativePositionGenericFilter<ArgsInfoType>::
24 RelativePositionGenericFilter():
25 ImageToImageGenericFilter<Self>("RelativePosition")
28 cmdline_parser_clitkRelativePosition_init(&mArgsInfo);
29 InitializeImageType<3>();
31 //--------------------------------------------------------------------
34 //--------------------------------------------------------------------
35 template<class ArgsInfoType>
36 template<unsigned int Dim>
37 void clitk::RelativePositionGenericFilter<ArgsInfoType>::
40 ADD_IMAGE_TYPE(Dim, uchar);
42 //--------------------------------------------------------------------
45 //--------------------------------------------------------------------
46 template<class ArgsInfoType>
47 void clitk::RelativePositionGenericFilter<ArgsInfoType>::
48 SetArgsInfo(const ArgsInfoType & a)
51 SetIOVerbose(mArgsInfo.verbose_flag);
52 if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes();
53 if (mArgsInfo.input_given) AddInputFilename(mArgsInfo.input_arg);
54 if (mArgsInfo.object_given) AddInputFilename(mArgsInfo.object_arg);
55 if (mArgsInfo.output_given) AddOutputFilename(mArgsInfo.output_arg);
57 //--------------------------------------------------------------------
60 //--------------------------------------------------------------------
61 // Update with the number of dimensions and the pixeltype
62 //--------------------------------------------------------------------
63 template<class ArgsInfoType>
64 template<class FilterType>
65 void clitk::RelativePositionGenericFilter<ArgsInfoType>::
66 SetOptionsFromArgsInfoToFilter(FilterType * f)
68 f->SetVerboseOptionFlag(mArgsInfo.verboseOptions_flag);
69 f->SetVerboseStepFlag(mArgsInfo.verboseStep_flag);
70 f->SetWriteStepFlag(mArgsInfo.writeStep_flag);
72 for(uint i=0; i<mArgsInfo.orientation_given; i++) {
73 f->AddOrientationTypeString(mArgsInfo.orientation_arg[i]);
76 if (mArgsInfo.spacing_given) {
77 f->IntermediateSpacingFlagOn();
78 f->SetIntermediateSpacing(mArgsInfo.spacing_arg);
81 f->SetFuzzyThreshold(mArgsInfo.threshold_arg);
82 f->SetRemoveObjectFlag(!mArgsInfo.doNotRemoveObject_flag);
83 f->SetAutoCropFlag(!mArgsInfo.noAutoCrop_flag);
84 f->SetCombineWithOrFlag(mArgsInfo.combineWithOr_flag);
85 f->SetInverseOrientationFlag(mArgsInfo.inverse_flag);
88 //--------------------------------------------------------------------
89 // Update with the number of dimensions and the pixeltype
90 //--------------------------------------------------------------------
91 template<class ArgsInfoType>
92 template<class ImageType>
93 void clitk::RelativePositionGenericFilter<ArgsInfoType>::
94 UpdateWithInputImageType()
97 typename ImageType::Pointer input = this->template GetInput<ImageType>(0);
98 typename ImageType::Pointer object = this->template GetInput<ImageType>(1);
100 if (mArgsInfo.sliceBySlice_flag) {
102 typedef clitk::SliceBySliceRelativePositionFilter<ImageType> FilterType;
103 typename FilterType::Pointer filter = FilterType::New();
105 // Set the filter (needed for example for threaded monitoring)
106 this->SetFilterBase(filter);
108 // Set global Options
109 filter->SetInput(input);
110 filter->SetInputObject(object);
111 SetOptionsFromArgsInfoToFilter<FilterType>(filter);
113 // Set options only for SliceBySliceRelativePositionFilter
114 filter->SetDirection(mArgsInfo.direction_arg);
115 filter->SetUniqueConnectedComponentBySlice(mArgsInfo.uniqueCCL_flag);
120 // Write/Save results
121 typename ImageType::Pointer output = filter->GetOutput();
122 this->template SetNextOutput<ImageType>(output);
126 typedef clitk::AddRelativePositionConstraintToLabelImageFilter<ImageType> FilterType;
127 typename FilterType::Pointer filter = FilterType::New();
129 // Set the filter (needed for example for threaded monitoring)
130 this->SetFilterBase(filter);
132 // Set global Options
133 filter->SetInput(input);
134 filter->SetInputObject(object);
135 if (mArgsInfo.angle1_given && mArgsInfo.angle2_given)
136 filter->AddAngles(mArgsInfo.angle1_arg, mArgsInfo.angle2_arg);
137 SetOptionsFromArgsInfoToFilter<FilterType>(filter);
142 // Write/Save results
143 typename ImageType::Pointer output = filter->GetOutput();
144 this->template SetNextOutput<ImageType>(output);
147 //--------------------------------------------------------------------