annotate OrthancStone/Sources/Toolbox/BucketAccumulator2D.cpp @ 2064:4e31d76c7ecd deep-learning

making ImageProcessingProgram compatible with 3D volumes
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 04 May 2023 11:06:19 +0200
parents 3f88c239043a
children 07964689cb0b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1891
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * modify it under the terms of the GNU Lesser General Public License
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * as published by the Free Software Foundation, either version 3 of
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * the License, or (at your option) any later version.
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * Lesser General Public License for more details.
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU Lesser General Public
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * License along with this program. If not, see
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * <http://www.gnu.org/licenses/>.
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "BucketAccumulator2D.h"
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "LinearAlgebra.h"
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 #include <OrthancException.h>
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 namespace OrthancStone
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 {
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 size_t BucketAccumulator2D::FindBestInternal() const
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 {
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 size_t best = 0;
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 for (size_t i = 0; i < buckets_.size(); i++)
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 {
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 if (buckets_[i].count_ > buckets_[best].count_)
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 {
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 best = i;
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 }
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 }
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 return best;
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 }
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 size_t BucketAccumulator2D::EncodeIndex(size_t x,
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 size_t y) const
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 {
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 if (x >= mapperX_.GetSize() ||
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 y >= mapperX_.GetSize())
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 {
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 }
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 else
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 {
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 return x + y * mapperX_.GetSize();
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 }
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 }
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 void BucketAccumulator2D::DecodeIndex(size_t& x,
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 size_t& y,
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 size_t index) const
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 {
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 assert(buckets_.size() == mapperX_.GetSize() * mapperY_.GetSize());
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 if (index >= buckets_.size())
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 {
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 }
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 else
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 {
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 x = index % mapperX_.GetSize();
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 y = index / mapperX_.GetSize();
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 }
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 }
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 BucketAccumulator2D::BucketAccumulator2D(double minValueX,
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 double maxValueX,
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 size_t countBucketsX,
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 double minValueY,
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 double maxValueY,
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 size_t countBucketsY,
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 bool storeValues) :
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 mapperX_(minValueX, maxValueX, countBucketsX),
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 mapperY_(minValueY, maxValueY, countBucketsY),
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 buckets_(countBucketsX * countBucketsY),
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 storeValues_(storeValues)
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 {
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 }
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 void BucketAccumulator2D::GetSize(size_t& x,
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 size_t& y) const
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 {
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 x = mapperX_.GetSize();
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 y = mapperY_.GetSize();
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 }
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 size_t BucketAccumulator2D::GetBucketContentSize(size_t x,
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 size_t y) const
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 {
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 return buckets_[EncodeIndex(x, y)].count_;
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 }
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 void BucketAccumulator2D::GetBucketIndex(size_t& bucketX,
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 size_t& bucketY,
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 double valueX,
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 double valueY) const
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 {
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 bucketX = mapperX_.GetBucketIndex(valueX);
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 bucketY = mapperY_.GetBucketIndex(valueY);
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 }
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 void BucketAccumulator2D::AddValue(double valueX,
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 double valueY)
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 {
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 size_t x = mapperX_.GetBucketIndex(valueX);
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 size_t y = mapperY_.GetBucketIndex(valueY);
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 Bucket& bucket = buckets_[EncodeIndex(x, y)];
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 bucket.count_++;
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 if (storeValues_)
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 {
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 bucket.valuesX_.push_back(valueX);
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 bucket.valuesY_.push_back(valueY);
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 }
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 }
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 void BucketAccumulator2D::ComputeBestCenter(double& x,
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 double& y) const
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 {
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 size_t bucketX, bucketY;
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 FindBestBucket(bucketX, bucketY);
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 x = mapperX_.GetBucketCenter(bucketX);
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 y = mapperY_.GetBucketCenter(bucketY);
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 }
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 void BucketAccumulator2D::ComputeBestMedian(double& x,
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 double& y) const
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 {
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 if (!storeValues_)
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 {
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 }
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 const std::list<double>& valuesX = buckets_[FindBestInternal()].valuesX_;
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 const std::list<double>& valuesY = buckets_[FindBestInternal()].valuesY_;
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 std::vector<double> v;
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 v.reserve(valuesX.size());
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 for (std::list<double>::const_iterator it = valuesX.begin(); it != valuesX.end(); ++it)
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 {
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 v.push_back(*it);
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 }
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 x = LinearAlgebra::ComputeMedian(v);
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 v.clear();
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 v.reserve(valuesY.size());
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 for (std::list<double>::const_iterator it = valuesY.begin(); it != valuesY.end(); ++it)
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 {
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 v.push_back(*it);
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 }
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 y = LinearAlgebra::ComputeMedian(v);
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 }
1892
cdf91ad891a5 estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1891
diff changeset
179
cdf91ad891a5 estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1891
diff changeset
180
cdf91ad891a5 estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1891
diff changeset
181 void BucketAccumulator2D::Print(FILE* fp) const
cdf91ad891a5 estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1891
diff changeset
182 {
cdf91ad891a5 estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1891
diff changeset
183 fprintf(fp, " ");
cdf91ad891a5 estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1891
diff changeset
184
cdf91ad891a5 estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1891
diff changeset
185 for (size_t x = 0; x < mapperX_.GetSize(); x++)
cdf91ad891a5 estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1891
diff changeset
186 {
cdf91ad891a5 estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1891
diff changeset
187 fprintf(fp, "%7.2f ", mapperX_.GetBucketCenter(x));
cdf91ad891a5 estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1891
diff changeset
188 }
cdf91ad891a5 estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1891
diff changeset
189
cdf91ad891a5 estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1891
diff changeset
190 fprintf(fp, "\n");
cdf91ad891a5 estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1891
diff changeset
191
cdf91ad891a5 estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1891
diff changeset
192 for (size_t y = 0; y < mapperY_.GetSize(); y++)
cdf91ad891a5 estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1891
diff changeset
193 {
cdf91ad891a5 estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1891
diff changeset
194 fprintf(fp, "%7.2f: ", mapperY_.GetBucketCenter(y));
cdf91ad891a5 estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1891
diff changeset
195
cdf91ad891a5 estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1891
diff changeset
196 for (size_t x = 0; x < mapperX_.GetSize(); x++)
cdf91ad891a5 estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1891
diff changeset
197 {
1957
3f88c239043a cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1916
diff changeset
198 fprintf(fp, "%7ld ", static_cast<long>(GetBucketContentSize(x, y)));
1892
cdf91ad891a5 estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1891
diff changeset
199 }
cdf91ad891a5 estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1891
diff changeset
200
cdf91ad891a5 estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1891
diff changeset
201 fprintf(fp, "\n");
cdf91ad891a5 estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1891
diff changeset
202 }
cdf91ad891a5 estimated geometry of rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1891
diff changeset
203 }
1891
3716d72161d2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 }