]> Creatis software - clitk.git/blob - segmentation/clitkStructuresExtractionFilter.txx
1562beaaf84959db30e4fee611a457975ae9f8b6
[clitk.git] / segmentation / clitkStructuresExtractionFilter.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 // clitk
20 #include "clitkStructuresExtractionFilter.h"
21
22 //--------------------------------------------------------------------
23 template <class TImageType>
24 clitk::StructuresExtractionFilter<TImageType>::
25 StructuresExtractionFilter():
26   clitk::FilterBase(),
27   clitk::FilterWithAnatomicalFeatureDatabaseManagement(),
28   itk::ImageToImageFilter<TImageType, MaskImageType>()
29 {
30   SetBackgroundValue(0);
31   SetForegroundValue(1);
32 }
33 //--------------------------------------------------------------------
34
35
36 //--------------------------------------------------------------------
37 template <class TImageType>
38 void 
39 clitk::StructuresExtractionFilter<TImageType>::
40 AddRelativePositionListFilename(std::string s) {
41   mListOfRelativePositionListFilename.push_back(s);
42 }
43 //--------------------------------------------------------------------
44
45
46 //--------------------------------------------------------------------
47 template <class TImageType>
48 typename clitk::StructuresExtractionFilter<TImageType>::MaskImagePointer
49 clitk::StructuresExtractionFilter<TImageType>::
50 ApplyRelativePositionList(std::string name, MaskImageType * input) 
51
52   // Create all RelativePositionList
53   for(int i=0; i<mListOfRelativePositionListFilename.size(); i++) {
54     RelPosListPointer rpl = RelPosListType::New();
55     rpl->SetAFDB(GetAFDB());
56     rpl->Read(mListOfRelativePositionListFilename[i]);
57     std::string s = rpl->GetInputName();
58     mMapOfRelativePositionList[s] = rpl;
59   }
60
61   RelPosListPointer relpos;
62   if (mMapOfRelativePositionList.find(name) == mMapOfRelativePositionList.end()) {
63     std::cerr << "Warning: I do not find '" << name << "' in the RelativePositionList." << std::endl;
64     //DD("Not find !"); // do nothing
65   }
66   else {
67     relpos = mMapOfRelativePositionList[name];
68     relpos->SetVerboseStepFlag(GetVerboseStepFlag());
69     relpos->SetCurrentStepBaseId(GetCurrentStepBaseId());
70     relpos->SetCurrentStepId(GetCurrentStepId());
71     relpos->SetCurrentStepNumber(GetCurrentStepNumber());
72     relpos->SetWriteStepFlag(GetWriteStepFlag());
73     relpos->SetInput(input);
74     relpos->Update();
75     input = relpos->GetOutput();
76     SetCurrentStepNumber(relpos->GetCurrentStepNumber());
77   }
78   return input;
79 }
80 //--------------------------------------------------------------------
81