Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Toolbox/BucketAccumulator1D.h @ 1891:3716d72161d2
reorganization
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 19 Jan 2022 12:32:15 +0100 |
parents | |
children | cdf91ad891a5 |
comparison
equal
deleted
inserted
replaced
1890:6ce81914f7e4 | 1891:3716d72161d2 |
---|---|
1 /** | |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium | |
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium | |
7 * | |
8 * This program is free software: you can redistribute it and/or | |
9 * modify it under the terms of the GNU Lesser General Public License | |
10 * as published by the Free Software Foundation, either version 3 of | |
11 * the License, or (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 * Lesser General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU Lesser General Public | |
19 * License along with this program. If not, see | |
20 * <http://www.gnu.org/licenses/>. | |
21 **/ | |
22 | |
23 | |
24 #pragma once | |
25 | |
26 #include "Internals/BucketMapper.h" | |
27 | |
28 #include <list> | |
29 #include <vector> | |
30 | |
31 | |
32 namespace OrthancStone | |
33 { | |
34 class BucketAccumulator1D : public boost::noncopyable | |
35 { | |
36 private: | |
37 struct Bucket | |
38 { | |
39 size_t count_; | |
40 std::list<double> values_; | |
41 }; | |
42 | |
43 Internals::BucketMapper mapper_; | |
44 std::vector<Bucket> buckets_; | |
45 bool storeValues_; | |
46 | |
47 public: | |
48 BucketAccumulator1D(double minValue, | |
49 double maxValue, | |
50 size_t countBuckets, | |
51 bool storeValues); | |
52 | |
53 size_t GetSize() const | |
54 { | |
55 return mapper_.GetSize(); | |
56 } | |
57 | |
58 double GetBucketLow(size_t i) const | |
59 { | |
60 return mapper_.GetBucketLow(i); | |
61 } | |
62 | |
63 double GetBucketHigh(size_t i) const | |
64 { | |
65 return mapper_.GetBucketHigh(i); | |
66 } | |
67 | |
68 double GetBucketCenter(size_t i) const | |
69 { | |
70 return mapper_.GetBucketCenter(i); | |
71 } | |
72 | |
73 size_t GetBucketContentSize(size_t i) const; | |
74 | |
75 size_t GetBucketIndex(double value) const | |
76 { | |
77 return mapper_.GetBucketIndex(value); | |
78 } | |
79 | |
80 void AddValue(double value); | |
81 | |
82 size_t FindBestBucket() const; | |
83 | |
84 double ComputeBestCenter() const | |
85 { | |
86 return GetBucketCenter(FindBestBucket()); | |
87 } | |
88 | |
89 double ComputeBestMedian() const; | |
90 }; | |
91 } |