SMIL  0.9.1
DBlobMeasures.hpp
1 /*
2  * Copyright (c) 2011-2016, Matthieu FAESSEL and ARMINES
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of Matthieu FAESSEL, or ARMINES nor the
14  * names of its contributors may be used to endorse or promote products
15  * derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY
18  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 
30 #ifndef _D_BLOB_MEASURES_HPP
31 #define _D_BLOB_MEASURES_HPP
32 
33 #include "Core/include/private/DImage.hpp"
34 #include "DImageHistogram.hpp"
35 #include "DMeasures.hpp"
36 
37 #include <map>
38 
39 using namespace std;
40 
41 namespace smil
42 {
43 
55  template <class T>
56  map<T, double> measAreas(const Image<T> &imLbl, const bool onlyNonZero=true)
57  {
58  return processBlobMeasure<T, T, measAreaFunc<T> >(imLbl, onlyNonZero);
59  }
60 
66  template <class labelT>
67  map<labelT, double> measAreas(map<labelT, Blob> &blobs)
68  {
69  Image<labelT> fakeImg(1, 1);
70  return processBlobMeasure<labelT, labelT, measAreaFunc<labelT> >(fakeImg, blobs);
71  }
72 
77  template <class T, class labelT>
78  map<labelT, T> measMinVals(const Image<T> &imIn, map<labelT, Blob> &blobs)
79  {
80  return processBlobMeasure<T, labelT, measMinValFunc<T> >(imIn, blobs);
81  }
82 
87  template <class T, class labelT>
88  map<labelT, T> measMaxVals(const Image<T> &imIn, map<labelT, Blob> &blobs)
89  {
90  return processBlobMeasure<T, labelT, measMaxValFunc<T> >(imIn, blobs);
91  }
92 
97  template <class T, class labelT>
98  map<labelT, vector<T> > measRangeVals(const Image<T> &imIn, map<labelT, Blob> &blobs)
99  {
100  return processBlobMeasure<T, labelT, measMinMaxValFunc<T> >(imIn, blobs);
101  }
102 
107  template <class T, class labelT>
108  map<labelT, Vector_double> measMeanVals(const Image<T> &imIn, map<labelT, Blob> &blobs)
109  {
110  return processBlobMeasure<T, labelT, measMeanValFunc<T> >(imIn, blobs);
111  }
112 
117  template <class T, class labelT>
118  map<labelT, double> measVolumes(const Image<T> &imIn, map<labelT, Blob> &blobs)
119  {
120  return processBlobMeasure<T, labelT, measVolFunc<T> >(imIn, blobs);
121  }
122 
123 
128  template <class T, class labelT>
129  map<labelT, vector<T> > valueLists(const Image<T> &imIn, map<labelT, Blob> &blobs)
130  {
131  return processBlobMeasure<T, labelT, valueListFunc<T> >(imIn, blobs);
132  }
137  template <class T, class labelT>
138  map<labelT, T > measModeVals(const Image<T> &imIn, map<labelT, Blob> &blobs)
139  {
140  return processBlobMeasure<T, labelT, measModeValFunc<T> >(imIn, blobs);
141  }
146  template <class T, class labelT>
147  map<labelT, T > measMedianVals(const Image<T> &imIn, map<labelT, Blob> &blobs)
148  {
149  return processBlobMeasure<T, labelT, measMedianValFunc<T> >(imIn, blobs);
150  }
151 
158  template <class T>
159  map<T, Vector_double> measBarycenters(const Image<T> &imLbl, const bool onlyNonZero=true)
160  {
161  return processBlobMeasure<T, T, measBarycenterFunc<T> >(imLbl, onlyNonZero);
162  }
163 
168  template <class T, class labelT>
169  map<labelT, Vector_double> measBarycenters(const Image<T> &imIn, map<labelT, Blob> &blobs)
170  {
171  return processBlobMeasure<T, labelT, measBarycenterFunc<T> >(imIn, blobs);
172  }
173 
174 
175 
180  template <class T>
181  map<T, vector<size_t> > measBoundBoxes(const Image<T> &imLbl, const bool onlyNonZero=true)
182  {
183  return processBlobMeasure<T, T, measBoundBoxFunc<T> >(imLbl, onlyNonZero);
184  }
185 
190  template <class T, class labelT>
191  map<labelT, vector<size_t> > measBoundBoxes(const Image<T> &imIn, map<labelT, Blob> &blobs)
192  {
193  return processBlobMeasure<T, labelT, measBoundBoxFunc<T> >(imIn, blobs);
194  }
195 
199  template <class T>
200  map<T, Vector_double> measInertiaMatrices(const Image<T> &imLbl, const bool onlyNonZero=true)
201  {
202  return processBlobMeasure<T, T, measInertiaMatrixFunc<T> >(imLbl, onlyNonZero);
203  }
204 
210  template <class T, class labelT>
211  map<labelT, Vector_double> measInertiaMatrices(const Image<T> &imIn, map<labelT, Blob> &blobs)
212  {
213  return processBlobMeasure<T, labelT, measInertiaMatrixFunc<T> >(imIn, blobs);
214  }
215 
218 } // namespace smil
219 
220 
221 #endif // _D_BLOB_MEASURES_HPP
222 
map< labelT, T > measMaxVals(const Image< T > &imIn, map< labelT, Blob > &blobs)
Measure the maximum value of each blob in imIn.
Definition: DBlobMeasures.hpp:88
Definition: DColorConvert.h:38
map< labelT, T > measModeVals(const Image< T > &imIn, map< labelT, Blob > &blobs)
Measure the mode value of imIn in each blob.
Definition: DBlobMeasures.hpp:138
map< labelT, vector< T > > valueLists(const Image< T > &imIn, map< labelT, Blob > &blobs)
Measure the list of values of each blob in imIn.
Definition: DBlobMeasures.hpp:129
map< labelT, T > measMedianVals(const Image< T > &imIn, map< labelT, Blob > &blobs)
Measure the median value of imIn in each blob.
Definition: DBlobMeasures.hpp:147
map< labelT, double > measVolumes(const Image< T > &imIn, map< labelT, Blob > &blobs)
Measure the sum of values of each blob in imIn.
Definition: DBlobMeasures.hpp:118
map< labelT, T > measMinVals(const Image< T > &imIn, map< labelT, Blob > &blobs)
Measure the minimum value of each blob in imIn.
Definition: DBlobMeasures.hpp:78
map< labelT, Vector_double > measMeanVals(const Image< T > &imIn, map< labelT, Blob > &blobs)
Measure the mean value and the std dev.
Definition: DBlobMeasures.hpp:108
Main Image class.
Definition: DQVtkViewer.hpp:44
map< labelT, Vector_double > measInertiaMatrices(const Image< T > &imIn, map< labelT, Blob > &blobs)
Measure blobs inertia moments.
Definition: DBlobMeasures.hpp:211
map< labelT, vector< T > > measRangeVals(const Image< T > &imIn, map< labelT, Blob > &blobs)
Measure the min and max values of each blob in imIn.
Definition: DBlobMeasures.hpp:98
map< labelT, double > measAreas(map< labelT, Blob > &blobs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: DBlobMeasures.hpp:67
map< labelT, vector< size_t > > measBoundBoxes(const Image< T > &imIn, map< labelT, Blob > &blobs)
Measure bounding boxes of each blob (faster with blobs pre-generated).
Definition: DBlobMeasures.hpp:191
map< labelT, Vector_double > measBarycenters(const Image< T > &imIn, map< labelT, Blob > &blobs)
Measure the barycenter of each blob in imIn.
Definition: DBlobMeasures.hpp:169