Mercurial > hg > orthanc-stone
annotate Framework/Volumes/VolumeReslicer.cpp @ 593:6bf8f881fcb5
OpenGLBasicPolylineRenderer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 26 Apr 2019 13:04:56 +0200 |
parents | 3080ec4ec6b9 |
children | 7719eb852dd5 |
rev | line source |
---|---|
186 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
439 | 5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
186 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 #include "VolumeReslicer.h" |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
159
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
24 #include "../Toolbox/GeometryToolbox.h" |
183 | 25 #include "../Toolbox/SubvoxelReader.h" |
159
0a73d76333db
populating LinearAlgebra
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
26 |
212
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
27 #include <Core/Images/ImageTraits.h> |
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
28 #include <Core/Logging.h> |
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
29 #include <Core/OrthancException.h> |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 #include <boost/math/special_functions/round.hpp> |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 namespace OrthancStone |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 // Anonymous namespace to avoid clashes between compilation modules |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 namespace |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 enum TransferFunction |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 TransferFunction_Copy, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 TransferFunction_Float, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 TransferFunction_Linear |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 }; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 |
185 | 46 template <Orthanc::PixelFormat InputFormat, |
47 Orthanc::PixelFormat OutputFormat, | |
48 ImageInterpolation Interpolation, | |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 TransferFunction Function> |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 class PixelShader; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 |
185 | 53 template <Orthanc::PixelFormat Format> |
54 class PixelShader<Format, | |
55 Format, | |
56 ImageInterpolation_Nearest, | |
57 TransferFunction_Copy> | |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 private: |
185 | 60 typedef SubvoxelReader<Format, ImageInterpolation_Nearest> VoxelReader; |
61 typedef Orthanc::PixelTraits<Format> PixelWriter; | |
62 | |
63 VoxelReader reader_; | |
64 | |
65 public: | |
66 PixelShader(const ImageBuffer3D& image, | |
67 float /* scaling */, | |
68 float /* offset */) : | |
69 reader_(image) | |
70 { | |
71 } | |
72 | |
73 ORTHANC_FORCE_INLINE | |
74 void Apply(typename PixelWriter::PixelType* pixel, | |
75 float volumeX, | |
76 float volumeY, | |
77 float volumeZ) | |
78 { | |
79 typename VoxelReader::PixelType value; | |
80 | |
81 if (!reader_.GetValue(value, volumeX, volumeY, volumeZ)) | |
82 { | |
83 VoxelReader::Traits::SetMinValue(value); | |
84 } | |
85 | |
86 *pixel = value; | |
87 } | |
88 }; | |
89 | |
90 | |
91 template <Orthanc::PixelFormat InputFormat, | |
92 Orthanc::PixelFormat OutputFormat> | |
93 class PixelShader<InputFormat, | |
94 OutputFormat, | |
95 ImageInterpolation_Nearest, | |
96 TransferFunction_Copy> | |
97 { | |
98 private: | |
99 typedef SubvoxelReader<InputFormat, ImageInterpolation_Nearest> VoxelReader; | |
100 typedef Orthanc::PixelTraits<OutputFormat> PixelWriter; | |
101 | |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 VoxelReader reader_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 public: |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 PixelShader(const ImageBuffer3D& image, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 float /* scaling */, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 float /* offset */) : |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 reader_(image) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 |
180
4da803580da9
remove macro ORTHANC_STONE_FORCE_INLINE
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
112 ORTHANC_FORCE_INLINE |
184
9523ce4f44cc
removing PixelWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
113 void Apply(typename PixelWriter::PixelType* pixel, |
177 | 114 float volumeX, |
115 float volumeY, | |
116 float volumeZ) | |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 { |
183 | 118 typename VoxelReader::PixelType value; |
119 | |
120 if (!reader_.GetValue(value, volumeX, volumeY, volumeZ)) | |
121 { | |
122 VoxelReader::Traits::SetMinValue(value); | |
123 } | |
124 | |
184
9523ce4f44cc
removing PixelWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
125 PixelWriter::FloatToPixel(*pixel, VoxelReader::Traits::PixelToFloat(value)); |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 }; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 |
185 | 130 template <Orthanc::PixelFormat InputFormat, |
131 Orthanc::PixelFormat OutputFormat, | |
132 ImageInterpolation Interpolation> | |
133 class PixelShader<InputFormat, | |
134 OutputFormat, | |
135 Interpolation, | |
136 TransferFunction_Float> | |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 private: |
185 | 139 typedef SubvoxelReader<InputFormat, Interpolation> VoxelReader; |
140 typedef Orthanc::PixelTraits<OutputFormat> PixelWriter; | |
141 | |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 VoxelReader reader_; |
183 | 143 float outOfVolume_; |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 public: |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 PixelShader(const ImageBuffer3D& image, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 float /* scaling */, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 float /* offset */) : |
183 | 149 reader_(image), |
150 outOfVolume_(static_cast<float>(std::numeric_limits<typename VoxelReader::PixelType>::min())) | |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 |
180
4da803580da9
remove macro ORTHANC_STONE_FORCE_INLINE
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
154 ORTHANC_FORCE_INLINE |
184
9523ce4f44cc
removing PixelWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
155 void Apply(typename PixelWriter::PixelType* pixel, |
177 | 156 float volumeX, |
157 float volumeY, | |
158 float volumeZ) | |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 { |
183 | 160 float value; |
161 | |
162 if (!reader_.GetFloatValue(value, volumeX, volumeY, volumeZ)) | |
163 { | |
164 value = outOfVolume_; | |
165 } | |
166 | |
184
9523ce4f44cc
removing PixelWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
167 PixelWriter::FloatToPixel(*pixel, value); |
183 | 168 } |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 }; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 |
185 | 172 template <Orthanc::PixelFormat InputFormat, |
173 Orthanc::PixelFormat OutputFormat, | |
174 ImageInterpolation Interpolation> | |
175 class PixelShader<InputFormat, | |
176 OutputFormat, | |
177 Interpolation, | |
178 TransferFunction_Linear> | |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 private: |
185 | 181 typedef SubvoxelReader<InputFormat, Interpolation> VoxelReader; |
182 typedef Orthanc::PixelTraits<OutputFormat> PixelWriter; | |
183 | |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 VoxelReader reader_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 float scaling_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
186 float offset_; |
183 | 187 float outOfVolume_; |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
188 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
189 public: |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
190 PixelShader(const ImageBuffer3D& image, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
191 float scaling, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 float offset) : |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
193 reader_(image), |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 scaling_(scaling), |
183 | 195 offset_(offset), |
196 outOfVolume_(static_cast<float>(std::numeric_limits<typename VoxelReader::PixelType>::min())) | |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
197 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
198 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
199 |
180
4da803580da9
remove macro ORTHANC_STONE_FORCE_INLINE
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
200 ORTHANC_FORCE_INLINE |
184
9523ce4f44cc
removing PixelWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
201 void Apply(typename PixelWriter::PixelType* pixel, |
177 | 202 float volumeX, |
203 float volumeY, | |
204 float volumeZ) | |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
205 { |
183 | 206 float value; |
207 | |
208 if (reader_.GetFloatValue(value, volumeX, volumeY, volumeZ)) | |
209 { | |
210 value = scaling_ * value + offset_; | |
211 } | |
212 else | |
213 { | |
214 value = outOfVolume_; | |
215 } | |
216 | |
184
9523ce4f44cc
removing PixelWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
217 PixelWriter::FloatToPixel(*pixel, value); |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
218 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
219 }; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
220 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
221 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
222 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
223 class FastRowIterator : public boost::noncopyable |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
224 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
225 private: |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
226 float position_[3]; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
227 float offset_[3]; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
228 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
229 public: |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
230 FastRowIterator(const Orthanc::ImageAccessor& slice, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
231 const Extent2D& extent, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
232 const CoordinateSystem3D& plane, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
233 const OrientedBoundingBox& box, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
234 unsigned int y) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
235 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
236 const double width = static_cast<double>(slice.GetWidth()); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
237 const double height = static_cast<double>(slice.GetHeight()); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
238 assert(y < height); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
239 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
240 Vector q1 = plane.MapSliceToWorldCoordinates |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
241 (extent.GetX1() + extent.GetWidth() * static_cast<double>(0) / static_cast<double>(width + 1), |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
242 extent.GetY1() + extent.GetHeight() * static_cast<double>(y) / static_cast<double>(height + 1)); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
243 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
244 Vector q2 = plane.MapSliceToWorldCoordinates |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
245 (extent.GetX1() + extent.GetWidth() * static_cast<double>(width - 1) / static_cast<double>(width + 1), |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
246 extent.GetY1() + extent.GetHeight() * static_cast<double>(y) / static_cast<double>(height + 1)); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
247 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
248 Vector r1, r2; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
249 box.ToInternalCoordinates(r1, q1); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
250 box.ToInternalCoordinates(r2, q2); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
251 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
252 position_[0] = static_cast<float>(r1[0]); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
253 position_[1] = static_cast<float>(r1[1]); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
254 position_[2] = static_cast<float>(r1[2]); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
255 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
256 Vector tmp = (r2 - r1) / static_cast<double>(width - 1); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
257 offset_[0] = static_cast<float>(tmp[0]); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
258 offset_[1] = static_cast<float>(tmp[1]); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
259 offset_[2] = static_cast<float>(tmp[2]); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
260 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
261 |
180
4da803580da9
remove macro ORTHANC_STONE_FORCE_INLINE
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
262 ORTHANC_FORCE_INLINE |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
263 void Next() |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
264 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
265 position_[0] += offset_[0]; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
266 position_[1] += offset_[1]; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
267 position_[2] += offset_[2]; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
268 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
269 |
180
4da803580da9
remove macro ORTHANC_STONE_FORCE_INLINE
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
270 ORTHANC_FORCE_INLINE |
177 | 271 void GetVolumeCoordinates(float& x, |
272 float& y, | |
273 float& z) const | |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
274 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
275 x = position_[0]; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
276 y = position_[1]; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
277 z = position_[2]; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
278 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
279 }; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
280 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
281 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
282 class SlowRowIterator : public boost::noncopyable |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
283 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
284 private: |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
285 const Orthanc::ImageAccessor& slice_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
286 const Extent2D& extent_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
287 const CoordinateSystem3D& plane_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
288 const OrientedBoundingBox& box_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
289 unsigned int x_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
290 unsigned int y_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
291 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
292 public: |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
293 SlowRowIterator(const Orthanc::ImageAccessor& slice, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
294 const Extent2D& extent, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
295 const CoordinateSystem3D& plane, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
296 const OrientedBoundingBox& box, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
297 unsigned int y) : |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
298 slice_(slice), |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
299 extent_(extent), |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
300 plane_(plane), |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
301 box_(box), |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
302 x_(0), |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
303 y_(y) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
304 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
305 assert(y_ < slice_.GetHeight()); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
306 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
307 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
308 void Next() |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
309 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
310 x_++; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
311 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
312 |
177 | 313 void GetVolumeCoordinates(float& x, |
314 float& y, | |
315 float& z) const | |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
316 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
317 assert(x_ < slice_.GetWidth()); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
318 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
319 const double width = static_cast<double>(slice_.GetWidth()); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
320 const double height = static_cast<double>(slice_.GetHeight()); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
321 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
322 Vector q = plane_.MapSliceToWorldCoordinates |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
323 (extent_.GetX1() + extent_.GetWidth() * static_cast<double>(x_) / (width + 1.0), |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
324 extent_.GetY1() + extent_.GetHeight() * static_cast<double>(y_) / (height + 1.0)); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
325 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
326 Vector r; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
327 box_.ToInternalCoordinates(r, q); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
328 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
329 x = static_cast<float>(r[0]); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
330 y = static_cast<float>(r[1]); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
331 z = static_cast<float>(r[2]); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
332 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
333 }; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
334 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
335 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
336 template <typename RowIterator, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
337 Orthanc::PixelFormat InputFormat, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
338 Orthanc::PixelFormat OutputFormat, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
339 ImageInterpolation Interpolation, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
340 TransferFunction Function> |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
341 static void ProcessImage(Orthanc::ImageAccessor& slice, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
342 const Extent2D& extent, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
343 const ImageBuffer3D& source, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
344 const CoordinateSystem3D& plane, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
345 const OrientedBoundingBox& box, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
346 float scaling, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
347 float offset) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
348 { |
185 | 349 typedef PixelShader<InputFormat, OutputFormat, Interpolation, Function> Shader; |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
350 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
351 const unsigned int outputWidth = slice.GetWidth(); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
352 const unsigned int outputHeight = slice.GetHeight(); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
353 |
183 | 354 const float sourceWidth = static_cast<float>(source.GetWidth()); |
355 const float sourceHeight = static_cast<float>(source.GetHeight()); | |
356 const float sourceDepth = static_cast<float>(source.GetDepth()); | |
357 | |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
358 Shader shader(source, scaling, offset); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
359 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
360 for (unsigned int y = 0; y < outputHeight; y++) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
361 { |
185 | 362 typedef typename Orthanc::ImageTraits<OutputFormat>::PixelType PixelType; |
363 PixelType* p = reinterpret_cast<PixelType*>(slice.GetRow(y)); | |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
364 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
365 RowIterator it(slice, extent, plane, box, y); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
366 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
367 for (unsigned int x = 0; x < outputWidth; x++, p++) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
368 { |
177 | 369 float volumeX, volumeY, volumeZ; |
370 it.GetVolumeCoordinates(volumeX, volumeY, volumeZ); | |
183 | 371 |
372 shader.Apply(p, | |
373 volumeX * sourceWidth, | |
374 volumeY * sourceHeight, | |
375 volumeZ * sourceDepth); | |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
376 it.Next(); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
377 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
378 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
379 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
380 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
381 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
382 template <typename RowIterator, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
383 Orthanc::PixelFormat InputFormat, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
384 Orthanc::PixelFormat OutputFormat> |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
385 static void ProcessImage(Orthanc::ImageAccessor& slice, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
386 const Extent2D& extent, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
387 const ImageBuffer3D& source, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
388 const CoordinateSystem3D& plane, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
389 const OrientedBoundingBox& box, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
390 ImageInterpolation interpolation, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
391 bool hasLinearFunction, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
392 float scaling, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
393 float offset) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
394 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
395 if (hasLinearFunction) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
396 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
397 switch (interpolation) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
398 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
399 case ImageInterpolation_Nearest: |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
400 ProcessImage<RowIterator, InputFormat, OutputFormat, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
401 ImageInterpolation_Nearest, TransferFunction_Linear> |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
402 (slice, extent, source, plane, box, scaling, offset); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
403 break; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
404 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
405 case ImageInterpolation_Bilinear: |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
406 ProcessImage<RowIterator, InputFormat, OutputFormat, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
407 ImageInterpolation_Bilinear, TransferFunction_Linear> |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
408 (slice, extent, source, plane, box, scaling, offset); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
409 break; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
410 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
411 case ImageInterpolation_Trilinear: |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
412 ProcessImage<RowIterator, InputFormat, OutputFormat, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
413 ImageInterpolation_Trilinear, TransferFunction_Linear> |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
414 (slice, extent, source, plane, box, scaling, offset); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
415 break; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
416 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
417 default: |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
418 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
419 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
420 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
421 else |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
422 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
423 switch (interpolation) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
424 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
425 case ImageInterpolation_Nearest: |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
426 ProcessImage<RowIterator, InputFormat, OutputFormat, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
427 ImageInterpolation_Nearest, TransferFunction_Copy> |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
428 (slice, extent, source, plane, box, 0, 0); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
429 break; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
430 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
431 case ImageInterpolation_Bilinear: |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
432 ProcessImage<RowIterator, InputFormat, OutputFormat, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
433 ImageInterpolation_Bilinear, TransferFunction_Float> |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
434 (slice, extent, source, plane, box, 0, 0); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
435 break; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
436 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
437 case ImageInterpolation_Trilinear: |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
438 ProcessImage<RowIterator, InputFormat, OutputFormat, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
439 ImageInterpolation_Trilinear, TransferFunction_Float> |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
440 (slice, extent, source, plane, box, 0, 0); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
441 break; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
442 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
443 default: |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
444 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
445 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
446 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
447 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
448 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
449 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
450 template <typename RowIterator> |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
451 static void ProcessImage(Orthanc::ImageAccessor& slice, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
452 const Extent2D& extent, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
453 const ImageBuffer3D& source, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
454 const CoordinateSystem3D& plane, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
455 const OrientedBoundingBox& box, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
456 ImageInterpolation interpolation, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
457 bool hasLinearFunction, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
458 float scaling, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
459 float offset) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
460 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
461 if (source.GetFormat() == Orthanc::PixelFormat_Grayscale16 && |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
462 slice.GetFormat() == Orthanc::PixelFormat_Grayscale8) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
463 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
464 ProcessImage<RowIterator, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
465 Orthanc::PixelFormat_Grayscale16, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
466 Orthanc::PixelFormat_Grayscale8> |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
467 (slice, extent, source, plane, box, interpolation, hasLinearFunction, scaling, offset); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
468 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
469 else if (source.GetFormat() == Orthanc::PixelFormat_Grayscale16 && |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
470 slice.GetFormat() == Orthanc::PixelFormat_Grayscale16) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
471 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
472 ProcessImage<RowIterator, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
473 Orthanc::PixelFormat_Grayscale16, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
474 Orthanc::PixelFormat_Grayscale16> |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
475 (slice, extent, source, plane, box, interpolation, hasLinearFunction, scaling, offset); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
476 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
477 else if (source.GetFormat() == Orthanc::PixelFormat_SignedGrayscale16 && |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
478 slice.GetFormat() == Orthanc::PixelFormat_BGRA32) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
479 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
480 ProcessImage<RowIterator, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
481 Orthanc::PixelFormat_SignedGrayscale16, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
482 Orthanc::PixelFormat_BGRA32> |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
483 (slice, extent, source, plane, box, interpolation, hasLinearFunction, scaling, offset); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
484 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
485 else if (source.GetFormat() == Orthanc::PixelFormat_Grayscale16 && |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
486 slice.GetFormat() == Orthanc::PixelFormat_BGRA32) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
487 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
488 ProcessImage<RowIterator, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
489 Orthanc::PixelFormat_Grayscale16, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
490 Orthanc::PixelFormat_BGRA32> |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
491 (slice, extent, source, plane, box, interpolation, hasLinearFunction, scaling, offset); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
492 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
493 else |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
494 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
495 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
496 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
497 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
498 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
499 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
500 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
501 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
502 void VolumeReslicer::CheckIterators(const ImageBuffer3D& source, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
503 const CoordinateSystem3D& plane, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
504 const OrientedBoundingBox& box) const |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
505 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
506 for (unsigned int y = 0; y < slice_->GetHeight(); y++) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
507 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
508 FastRowIterator fast(*slice_, extent_, plane, box, y); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
509 SlowRowIterator slow(*slice_, extent_, plane, box, y); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
510 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
511 for (unsigned int x = 0; x < slice_->GetWidth(); x++) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
512 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
513 float px, py, pz; |
177 | 514 fast.GetVolumeCoordinates(px, py, pz); |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
515 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
516 float qx, qy, qz; |
177 | 517 slow.GetVolumeCoordinates(qx, qy, qz); |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
518 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
519 Vector d; |
158
a053ca7fa5c6
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
154
diff
changeset
|
520 LinearAlgebra::AssignVector(d, px - qx, py - qy, pz - qz); |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
521 double norm = boost::numeric::ublas::norm_2(d); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
522 if (norm > 0.0001) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
523 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
524 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
525 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
526 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
527 fast.Next(); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
528 slow.Next(); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
529 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
530 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
531 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
532 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
533 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
534 void VolumeReslicer::Reset() |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
535 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
536 success_ = false; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
537 extent_.Reset(); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
538 slice_.reset(NULL); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
539 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
540 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
541 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
542 float VolumeReslicer::GetMinOutputValue() const |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
543 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
544 switch (outputFormat_) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
545 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
546 case Orthanc::PixelFormat_Grayscale8: |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
547 case Orthanc::PixelFormat_Grayscale16: |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
548 case Orthanc::PixelFormat_BGRA32: |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
549 return 0.0f; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
550 break; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
551 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
552 default: |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
553 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
554 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
555 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
556 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
557 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
558 float VolumeReslicer::GetMaxOutputValue() const |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
559 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
560 switch (outputFormat_) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
561 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
562 case Orthanc::PixelFormat_Grayscale8: |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
563 case Orthanc::PixelFormat_BGRA32: |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
564 return static_cast<float>(std::numeric_limits<uint8_t>::max()); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
565 break; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
566 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
567 case Orthanc::PixelFormat_Grayscale16: |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
568 return static_cast<float>(std::numeric_limits<uint16_t>::max()); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
569 break; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
570 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
571 default: |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
572 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
573 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
574 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
575 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
576 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
577 VolumeReslicer::VolumeReslicer() : |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
578 outputFormat_(Orthanc::PixelFormat_Grayscale8), |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
579 interpolation_(ImageInterpolation_Nearest), |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
580 fastMode_(true), |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
581 success_(false) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
582 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
583 ResetLinearFunction(); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
584 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
585 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
586 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
587 void VolumeReslicer::GetLinearFunction(float& scaling, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
588 float& offset) const |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
589 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
590 if (hasLinearFunction_) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
591 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
592 scaling = scaling_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
593 offset = offset_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
594 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
595 else |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
596 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
597 scaling = 1.0f; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
598 offset = 0.0f; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
599 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
600 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
601 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
602 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
603 void VolumeReslicer::ResetLinearFunction() |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
604 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
605 Reset(); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
606 hasLinearFunction_ = false; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
607 scaling_ = 1.0f; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
608 offset_ = 0.0f; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
609 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
610 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
611 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
612 void VolumeReslicer::SetLinearFunction(float scaling, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
613 float offset) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
614 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
615 Reset(); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
616 hasLinearFunction_ = true; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
617 scaling_ = scaling; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
618 offset_ = offset; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
619 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
620 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
621 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
622 void VolumeReslicer::SetWindow(float low, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
623 float high) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
624 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
625 //printf("Range in pixel values: %f->%f\n", low, high); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
626 float scaling = (GetMaxOutputValue() - GetMinOutputValue()) / (high - low); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
627 float offset = GetMinOutputValue() - scaling * low; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
628 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
629 SetLinearFunction(scaling, offset); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
630 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
631 /*float x = scaling_ * low + offset_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
632 float y = scaling_ * high + offset_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
633 printf("%f %f (should be %f->%f)\n", x, y, GetMinOutputValue(), GetMaxOutputValue());*/ |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
634 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
635 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
636 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
637 void VolumeReslicer::FitRange(const ImageBuffer3D& image) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
638 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
639 float minInputValue, maxInputValue; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
640 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
641 if (!image.GetRange(minInputValue, maxInputValue) || |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
642 maxInputValue < 1) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
643 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
644 ResetLinearFunction(); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
645 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
646 else |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
647 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
648 SetWindow(minInputValue, maxInputValue); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
649 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
650 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
651 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
652 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
653 void VolumeReslicer::SetWindowing(ImageWindowing windowing, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
654 const ImageBuffer3D& image, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
655 float rescaleSlope, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
656 float rescaleIntercept) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
657 { |
589
3080ec4ec6b9
removed enum value: ImageWindowing_Default
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
658 if (windowing == ImageWindowing_Custom) |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
659 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
660 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
661 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
662 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
663 float center, width; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
664 ComputeWindowing(center, width, windowing, 0, 0); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
665 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
666 float a = (center - width / 2.0f - rescaleIntercept) / rescaleSlope; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
667 float b = (center + width / 2.0f - rescaleIntercept) / rescaleSlope; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
668 SetWindow(a, b); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
669 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
670 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
671 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
672 void VolumeReslicer::SetOutputFormat(Orthanc::PixelFormat format) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
673 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
674 if (format != Orthanc::PixelFormat_Grayscale8 && |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
675 format != Orthanc::PixelFormat_Grayscale16 && |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
676 format != Orthanc::PixelFormat_BGRA32) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
677 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
678 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
679 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
680 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
681 if (hasLinearFunction_) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
682 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
683 LOG(WARNING) << "Calls to VolumeReslicer::SetOutputFormat() should be done before VolumeReslicer::FitRange()"; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
684 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
685 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
686 outputFormat_ = format; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
687 Reset(); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
688 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
689 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
690 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
691 void VolumeReslicer::SetInterpolation(ImageInterpolation interpolation) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
692 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
693 if (interpolation != ImageInterpolation_Nearest && |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
694 interpolation != ImageInterpolation_Bilinear && |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
695 interpolation != ImageInterpolation_Trilinear) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
696 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
697 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
698 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
699 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
700 interpolation_ = interpolation; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
701 Reset(); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
702 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
703 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
704 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
705 const Extent2D& VolumeReslicer::GetOutputExtent() const |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
706 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
707 if (success_) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
708 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
709 return extent_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
710 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
711 else |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
712 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
713 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
714 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
715 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
716 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
717 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
718 const Orthanc::ImageAccessor& VolumeReslicer::GetOutputSlice() const |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
719 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
720 if (success_) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
721 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
722 assert(slice_.get() != NULL); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
723 return *slice_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
724 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
725 else |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
726 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
727 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
728 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
729 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
730 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
731 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
732 Orthanc::ImageAccessor* VolumeReslicer::ReleaseOutputSlice() |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
733 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
734 if (success_) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
735 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
736 assert(slice_.get() != NULL); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
737 success_ = false; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
738 return slice_.release(); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
739 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
740 else |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
741 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
742 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
743 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
744 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
745 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
746 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
747 void VolumeReslicer::Apply(const ImageBuffer3D& source, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
748 const CoordinateSystem3D& plane) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
749 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
750 // Choose the default voxel size as the finest voxel dimension |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
751 // of the source volumetric image |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
752 const OrthancStone::Vector dim = source.GetVoxelDimensions(OrthancStone::VolumeProjection_Axial); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
753 double voxelSize = dim[0]; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
754 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
755 if (dim[1] < voxelSize) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
756 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
757 voxelSize = dim[1]; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
758 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
759 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
760 if (dim[2] < voxelSize) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
761 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
762 voxelSize = dim[2]; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
763 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
764 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
765 if (voxelSize <= 0) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
766 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
767 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
768 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
769 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
770 Apply(source, plane, voxelSize); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
771 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
772 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
773 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
774 void VolumeReslicer::Apply(const ImageBuffer3D& source, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
775 const CoordinateSystem3D& plane, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
776 double voxelSize) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
777 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
778 Reset(); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
779 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
780 // Firstly, compute the intersection of the source volumetric |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
781 // image with the reslicing plane. This leads to a polygon with 3 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
782 // to 6 vertices. We compute the extent of the intersection |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
783 // polygon, with respect to the coordinate system of the reslicing |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
784 // plane. |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
785 OrientedBoundingBox box(source); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
786 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
787 if (!box.ComputeExtent(extent_, plane)) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
788 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
789 // The plane does not intersect with the bounding box of the volume |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
790 slice_.reset(new Orthanc::Image(outputFormat_, 0, 0, false)); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
791 success_ = true; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
792 return; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
793 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
794 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
795 // Secondly, the extent together with the voxel size gives the |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
796 // size of the output image |
172 | 797 unsigned int width = boost::math::iround(extent_.GetWidth() / voxelSize); |
798 unsigned int height = boost::math::iround(extent_.GetHeight() / voxelSize); | |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
799 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
800 slice_.reset(new Orthanc::Image(outputFormat_, width, height, false)); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
801 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
802 //CheckIterators(source, plane, box); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
803 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
804 if (fastMode_) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
805 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
806 ProcessImage<FastRowIterator>(*slice_, extent_, source, plane, box, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
807 interpolation_, hasLinearFunction_, scaling_, offset_); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
808 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
809 else |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
810 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
811 ProcessImage<SlowRowIterator>(*slice_, extent_, source, plane, box, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
812 interpolation_, hasLinearFunction_, scaling_, offset_); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
813 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
814 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
815 success_ = true; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
816 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
817 } |