Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Toolbox/SubvoxelReader.h @ 1783:75d3e2ab1fe1
BREAKING: SubvoxelReader using the same Z-axis ordering as ImageBuffer3D
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 14 May 2021 18:30:24 +0200 |
parents | 9ac2a65d4172 |
children | 3889ae96d2e9 |
comparison
equal
deleted
inserted
replaced
1782:f053c80ea411 | 1783:75d3e2ab1fe1 |
---|---|
32 | 32 |
33 namespace OrthancStone | 33 namespace OrthancStone |
34 { | 34 { |
35 namespace Internals | 35 namespace Internals |
36 { | 36 { |
37 /* | |
38 WARNING : the slice order is different between this class and ImageBuffer3D | |
39 | |
40 See the comment above ImageBuffer3D declaration. | |
41 | |
42 The slices are supposed to be stored in INCREASING z-order in this class! | |
43 */ | |
44 class SubvoxelReaderBase : public boost::noncopyable | 37 class SubvoxelReaderBase : public boost::noncopyable |
45 { | 38 { |
46 private: | 39 private: |
47 const ImageBuffer3D& source_; | 40 const ImageBuffer3D& source_; |
48 unsigned int width_; | 41 unsigned int width_; |
84 | 77 |
85 ORTHANC_FORCE_INLINE | 78 ORTHANC_FORCE_INLINE |
86 unsigned int ComputeRow(unsigned int y, | 79 unsigned int ComputeRow(unsigned int y, |
87 unsigned int z) const | 80 unsigned int z) const |
88 { | 81 { |
89 return z * height_ + y; | 82 /** |
83 * The "(depth_ - 1 - z)" comes from the fact that | |
84 * "ImageBuffer3D" class stores its slices in DECREASING | |
85 * z-order along the normal. This computation makes the | |
86 * "SubvoxelReader" class use the same convention as | |
87 * "ImageBuffer3D::GetVoxelXXX()". | |
88 * | |
89 * WARNING: Until changeset 1782:f053c80ea411, "z" was | |
90 * directly used, causing this class to have a slice order | |
91 * that was reversed between "SubvoxelReader" and | |
92 * "ImageBuffer3D". This notably made | |
93 * "DicomVolumeImageMPRSlicer" and "DicomVolumeImageReslicer" | |
94 * inconsistent in sagittal and coronal views (the texture was | |
95 * flipped along the Y-axis in the canvas). | |
96 **/ | |
97 return (depth_ - 1 - z) * height_ + y; | |
90 } | 98 } |
91 }; | 99 }; |
92 } | 100 } |
93 | 101 |
94 | 102 |
95 /* | |
96 WARNING : the slice order is different between this class and ImageBuffer3D | |
97 | |
98 See the comment above ImageBuffer3D declaration. | |
99 | |
100 The slices are supposed to be stored in INCREASING z-order in this class! | |
101 */ | |
102 template <Orthanc::PixelFormat Format, | 103 template <Orthanc::PixelFormat Format, |
103 ImageInterpolation Interpolation> | 104 ImageInterpolation Interpolation> |
104 class SubvoxelReader; | 105 class SubvoxelReader; |
105 | 106 |
106 | 107 |
107 /* | |
108 WARNING : the slice order is different between this class and ImageBuffer3D | |
109 | |
110 See the comment above ImageBuffer3D declaration. | |
111 | |
112 The slices are supposed to be stored in INCREASING z-order in this class! | |
113 */ | |
114 template <Orthanc::PixelFormat Format> | 108 template <Orthanc::PixelFormat Format> |
115 class SubvoxelReader<Format, ImageInterpolation_Nearest> : | 109 class SubvoxelReader<Format, ImageInterpolation_Nearest> : |
116 public Internals::SubvoxelReaderBase | 110 public Internals::SubvoxelReaderBase |
117 { | 111 { |
118 public: | 112 public: |
134 float y, | 128 float y, |
135 float z) const; | 129 float z) const; |
136 }; | 130 }; |
137 | 131 |
138 | 132 |
139 /* | |
140 WARNING : the slice order is different between this class and ImageBuffer3D | |
141 | |
142 See the comment above ImageBuffer3D declaration. | |
143 | |
144 The slices are supposed to be stored in INCREASING z-order in this class! | |
145 */ | |
146 template <Orthanc::PixelFormat Format> | 133 template <Orthanc::PixelFormat Format> |
147 class SubvoxelReader<Format, ImageInterpolation_Bilinear> : | 134 class SubvoxelReader<Format, ImageInterpolation_Bilinear> : |
148 public Internals::SubvoxelReaderBase | 135 public Internals::SubvoxelReaderBase |
149 { | 136 { |
150 public: | 137 public: |
174 float y, | 161 float y, |
175 float z) const; | 162 float z) const; |
176 }; | 163 }; |
177 | 164 |
178 | 165 |
179 /* | |
180 WARNING : the slice order is different between this class and ImageBuffer3D | |
181 | |
182 See the comment above ImageBuffer3D declaration. | |
183 | |
184 The slices are supposed to be stored in INCREASING z-order in this class! | |
185 */ | |
186 template <Orthanc::PixelFormat Format> | 166 template <Orthanc::PixelFormat Format> |
187 class SubvoxelReader<Format, ImageInterpolation_Trilinear> : | 167 class SubvoxelReader<Format, ImageInterpolation_Trilinear> : |
188 public Internals::SubvoxelReaderBase | 168 public Internals::SubvoxelReaderBase |
189 { | 169 { |
190 private: | 170 private: |
210 float y, | 190 float y, |
211 float z) const; | 191 float z) const; |
212 }; | 192 }; |
213 | 193 |
214 | 194 |
215 /* | |
216 See important comment above | |
217 */ | |
218 | |
219 template <Orthanc::PixelFormat Format> | 195 template <Orthanc::PixelFormat Format> |
220 bool SubvoxelReader<Format, ImageInterpolation_Nearest>::GetValue(PixelType& target, | 196 bool SubvoxelReader<Format, ImageInterpolation_Nearest>::GetValue(PixelType& target, |
221 float x, | 197 float x, |
222 float y, | 198 float y, |
223 float z) const | 199 float z) const |
266 { | 242 { |
267 return false; | 243 return false; |
268 } | 244 } |
269 } | 245 } |
270 | 246 |
271 | |
272 /* | |
273 See important comment above | |
274 */ | |
275 | 247 |
276 template <Orthanc::PixelFormat Format> | 248 template <Orthanc::PixelFormat Format> |
277 bool SubvoxelReader<Format, ImageInterpolation_Bilinear>::Sample(float& f00, | 249 bool SubvoxelReader<Format, ImageInterpolation_Bilinear>::Sample(float& f00, |
278 float& f01, | 250 float& f01, |
279 float& f10, | 251 float& f10, |
324 | 296 |
325 return true; | 297 return true; |
326 } | 298 } |
327 | 299 |
328 | 300 |
329 /* | |
330 See important comment above | |
331 */ | |
332 | |
333 template <Orthanc::PixelFormat Format> | 301 template <Orthanc::PixelFormat Format> |
334 bool SubvoxelReader<Format, ImageInterpolation_Bilinear>::GetFloatValue(float& target, | 302 bool SubvoxelReader<Format, ImageInterpolation_Bilinear>::GetFloatValue(float& target, |
335 float x, | 303 float x, |
336 float y, | 304 float y, |
337 float z) const | 305 float z) const |
366 } | 334 } |
367 } | 335 } |
368 } | 336 } |
369 | 337 |
370 | 338 |
371 /* | |
372 See important comment above | |
373 */ | |
374 | |
375 template <Orthanc::PixelFormat Format> | 339 template <Orthanc::PixelFormat Format> |
376 bool SubvoxelReader<Format, ImageInterpolation_Bilinear>::GetValue(PixelType& target, | 340 bool SubvoxelReader<Format, ImageInterpolation_Bilinear>::GetValue(PixelType& target, |
377 float x, | 341 float x, |
378 float y, | 342 float y, |
379 float z) const | 343 float z) const |
388 else | 352 else |
389 { | 353 { |
390 return false; | 354 return false; |
391 } | 355 } |
392 } | 356 } |
393 | |
394 | 357 |
395 | 358 |
396 template <Orthanc::PixelFormat Format> | 359 template <Orthanc::PixelFormat Format> |
397 bool SubvoxelReader<Format, ImageInterpolation_Trilinear>::GetFloatValue(float& target, | 360 bool SubvoxelReader<Format, ImageInterpolation_Trilinear>::GetFloatValue(float& target, |
398 float x, | 361 float x, |
443 } | 406 } |
444 } | 407 } |
445 } | 408 } |
446 | 409 |
447 | 410 |
448 /* | |
449 See important comment above | |
450 */ | |
451 | |
452 | |
453 template <Orthanc::PixelFormat Format> | 411 template <Orthanc::PixelFormat Format> |
454 bool SubvoxelReader<Format, ImageInterpolation_Trilinear>::GetValue(PixelType& target, | 412 bool SubvoxelReader<Format, ImageInterpolation_Trilinear>::GetValue(PixelType& target, |
455 float x, | 413 float x, |
456 float y, | 414 float y, |
457 float z) const | 415 float z) const |