]> Creatis software - STMS.git/blob - Lib/PrePostProcessing/itkSTMS_ImageSequenceToTemporalSet.h
First Relase on creatis's public git!
[STMS.git] / Lib / PrePostProcessing / itkSTMS_ImageSequenceToTemporalSet.h
1 /*
2  #
3  #  File        : itkSTMS_ImageSequenceToTemporalSet.h
4  #                ( C++ header file - STMS )
5  #
6  #  Description : STMS lib that implements the STMS filter and clustering.
7  #                This file is a part of the STMS Library project.
8  #                ( https://www.creatis.insa-lyon.fr/site7/fr/realisations )
9  #
10  #  [1] S. Mure, Grenier, T., Meier, S., Guttmann, R. G., et Benoit-Cattin, H.,
11  #       « Unsupervised spatio-temporal filtering of image sequences. A mean-shift specification »,
12  #       Pattern Recognition Letters, vol. 68, Part 1, p. 48 - 55, 2015.
13  #
14  #  Copyright   : Thomas GRENIER - Simon MURE
15  #                ( https://www.creatis.insa-lyon.fr/~grenier/ )
16  #
17  #  License     : CeCILL C
18  #                ( http://www.cecill.info/licences/Licence_CeCILL-C_V1-en.txt )
19  #
20  #  This software is governed by the CeCILL  license under French law and
21  #  abiding by the rules of distribution of free software.  You can  use,
22  #  modify and/ or redistribute the software under the terms of the CeCILL
23  #  license as circulated by CEA, CNRS and INRIA at the following URL
24  #  "http://www.cecill.info".
25  #
26  #  As a counterpart to the access to the source code and  rights to copy,
27  #  modify and redistribute granted by the license, users are provided only
28  #  with a limited warranty  and the software's author,  the holder of the
29  #  economic rights,  and the successive licensors  have only  limited
30  #  liability.
31  #
32  #  In this respect, the user's attention is drawn to the risks associated
33  #  with loading,  using,  modifying and/or developing or reproducing the
34  #  software by the user in light of its specific status of free software,
35  #  that may mean  that it is complicated to manipulate,  and  that  also
36  #  therefore means  that it is reserved for developers  and  experienced
37  #  professionals having in-depth computer knowledge. Users are therefore
38  #  encouraged to load and test the software's suitability as regards their
39  #  requirements in conditions enabling the security of their systems and/or
40  #  data to be ensured and,  more generally, to use and operate it in the
41  #  same conditions as regards security.
42  #
43  #  The fact that you are presently reading this means that you have had
44  #  knowledge of the CeCILL license and that you accept its terms.
45  #
46 */
47 /* Please don't forget to cite our work :
48   @article {MURE-15a,
49     title = {Unsupervised spatio-temporal filtering of image sequences. A mean-shift specification},
50     journal = {Pattern Recognition Letters},
51     volume = {68, Part 1},
52     year = {2015},
53     pages = {48 - 55},
54     issn = {0167-8655},
55     doi = {http://dx.doi.org/10.1016/j.patrec.2015.07.021},
56     url = {http://www.sciencedirect.com/science/article/pii/S0167865515002305},
57     author = {S. Mure and T Grenier and Meier, S. and Guttmann, R.G. and H. Benoit-Cattin}
58 }
59 */
60 #ifndef itkSTMS_ImageSequenceToTemporalSet_h
61 #define itkSTMS_ImageSequenceToTemporalSet_h
62
63 #include <string>
64 #include <vector>
65 //#include <array>
66
67 #include "itkImage.h"
68 #include "itkSTMS_XMLFileParser.h"
69 #include "itkSTMS_ArgumentsAnalysis.h"
70 #include "itkImageFileReader.h"
71 #include "itkImageRegionConstIteratorWithIndex.h"
72 #include "itkMinimumMaximumImageCalculator.h"
73
74 #ifndef STMS_NUMBERING_FORM_ONE
75 #define STMS_NUMBERING_FORM_ONE "1"
76 #endif
77
78 namespace itkSTMS
79 {
80     template < class ImageType, class MaskImageType >
81     class itkSTMS_ImageSequenceToTemporalSet
82     {
83
84     public:
85         // Reader typedefs
86         typedef itk::ImageFileReader< ImageType >      ReaderType;
87         typedef typename ReaderType::Pointer           ReaderPointer;
88         typedef itk::ImageFileReader< MaskImageType >  MaskReaderType;
89         typedef typename MaskReaderType::Pointer       MaskReaderPointer;
90
91         // Mask processing typedefs
92         typedef itk::MinimumMaximumImageCalculator< MaskImageType >
93                 MinMaxCalculatorType;
94         typedef typename MinMaxCalculatorType::Pointer MinMaxCalculatorPointer;
95
96         // Iterator typedefs
97         typedef itk::ImageRegionConstIteratorWithIndex< ImageType >     IteratorType;
98         typedef itk::ImageRegionConstIteratorWithIndex< MaskImageType > MaskIteratorType;
99
100         // Sample set typedefs
101         typedef unsigned int                            IndexType;
102         typedef float                                   SpatialType;
103         typedef typename ImageType::PixelType           PixelType;
104
105         typedef typename ImageType::Pointer             ImagePointer;
106         typedef typename ImageType::ConstPointer        ImageConstPointer;
107         typedef typename ImageType::SizeType            SizeType;
108
109         typedef std::vector< SpatialType >              SpatialVectorType;
110         typedef std::vector< PixelType >                RangeVectorType;
111
112         typedef std::vector< IndexType >                IndexSampleSetType;
113         typedef std::vector< SpatialVectorType >        SpatialSampleSetType;
114         typedef std::vector< RangeVectorType >          RangeSampleSetType;
115
116         // Mask image typedefs
117         typedef typename MaskImageType::PixelType       MaskPixelType;
118         typedef typename MaskImageType::Pointer         MaskImagePointer;
119         typedef typename MaskImageType::ConstPointer    MaskImageConstPointer;
120
121         // Methods
122         itkSTMS_ImageSequenceToTemporalSet( itkSTMS::ParamsAnalysisOutputType* stmsParameters );
123         inline ~itkSTMS_ImageSequenceToTemporalSet(){ delete xmlParser; }
124
125         void GenerateDataSets();
126
127         inline IndexSampleSetType*   GetIndexSet  (){ return &indexSet;   }
128         inline IndexSampleSetType*   GetClassSet  (){ return &classSet;   }
129         inline IndexSampleSetType*   GetMergingSet(){ return &mergingSet; }
130         inline IndexSampleSetType*   GetWeightsSet(){ return &weightsSet; }
131         inline SpatialSampleSetType* GetSpatialSet(){ return &spatialSet; }
132         inline RangeSampleSetType*   GetRangeSet  (){ return &rangeSet;   }
133
134         inline itkSTMS::ParserOutputType* GetExperimentDescription(){ return expDescription; }
135
136     private:
137         // Attributes
138         itkSTMS::itkSTMS_XMLFileParser*    xmlParser;
139         itkSTMS::ParserOutputType*         expDescription;
140         itkSTMS::ParamsAnalysisOutputType* stmsParameters;
141
142         IndexSampleSetType      indexSet,
143                                 classSet,
144                                 mergingSet,
145                                 weightsSet;
146         SpatialSampleSetType    spatialSet;
147         RangeSampleSetType      rangeSet;
148
149         MaskPixelType           maskValue;
150         MaskImagePointer        mask;
151         MaskReaderPointer       mReader;
152         MinMaxCalculatorPointer MinMaxCalculator;
153         std::string             maskPath;
154         MaskIteratorType        mIt;
155
156     };  // end of class itkSTMS_ImageSequenceToTemporalSet
157 } // end of namespace itkstms
158
159 #ifndef ITK_MANUAL_INSTANTIATION
160 #include "itkSTMS_ImageSequenceToTemporalSet.txx"
161 #endif
162
163 #endif