Mercurial > hg > orthanc-stone
annotate Framework/Volumes/ImageBuffer3D.cpp @ 525:2549363fadc3 am-touch-events
Close branch am-touch-events.
author | Alain Mazy <am@osimis.io> |
---|---|
date | Tue, 12 Mar 2019 17:29:12 +0000 |
parents | b70e9be013e4 |
children | e9339f2b5de7 |
rev | line source |
---|---|
0 | 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 |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
47 | 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. | |
0 | 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 | |
47 | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Affero General Public License for more details. | |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
16 * |
47 | 17 * You should have received a copy of the GNU Affero General Public License |
0 | 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 **/ | |
20 | |
21 | |
22 #include "ImageBuffer3D.h" | |
23 | |
212
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
24 #include <Core/Images/ImageProcessing.h> |
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
25 #include <Core/Logging.h> |
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
26 #include <Core/OrthancException.h> |
0 | 27 |
87
4a541cd4fa83
OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
28 #include <string.h> |
0 | 29 |
30 namespace OrthancStone | |
31 { | |
316
ce48c3b3b0e9
fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
32 void ImageBuffer3D::GetAxialSliceAccessor(Orthanc::ImageAccessor& target, |
ce48c3b3b0e9
fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
33 unsigned int slice, |
ce48c3b3b0e9
fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
34 bool readOnly) const |
0 | 35 { |
36 if (slice >= depth_) | |
37 { | |
38 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
39 } | |
40 | |
41 if (readOnly) | |
42 { | |
316
ce48c3b3b0e9
fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
43 target.AssignReadOnly(format_, width_, height_, image_.GetPitch(), |
ce48c3b3b0e9
fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
44 image_.GetConstRow(height_ * (depth_ - 1 - slice))); |
0 | 45 } |
46 else | |
47 { | |
316
ce48c3b3b0e9
fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
48 target.AssignWritable(format_, width_, height_, image_.GetPitch(), |
ce48c3b3b0e9
fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
49 image_.GetRow(height_ * (depth_ - 1 - slice))); |
0 | 50 } |
51 } | |
52 | |
53 | |
316
ce48c3b3b0e9
fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
54 void ImageBuffer3D::GetCoronalSliceAccessor(Orthanc::ImageAccessor& target, |
ce48c3b3b0e9
fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
55 unsigned int slice, |
ce48c3b3b0e9
fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
56 bool readOnly) const |
0 | 57 { |
58 if (slice >= height_) | |
59 { | |
60 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
61 } | |
62 | |
63 if (readOnly) | |
64 { | |
316
ce48c3b3b0e9
fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
65 target.AssignReadOnly(format_, width_, depth_, image_.GetPitch() * height_, |
ce48c3b3b0e9
fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
66 image_.GetConstRow(slice)); |
0 | 67 } |
68 else | |
69 { | |
316
ce48c3b3b0e9
fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
70 target.AssignWritable(format_, width_, depth_, image_.GetPitch() * height_, |
ce48c3b3b0e9
fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
71 image_.GetRow(slice)); |
0 | 72 } |
73 } | |
74 | |
75 | |
76 Orthanc::Image* ImageBuffer3D::ExtractSagittalSlice(unsigned int slice) const | |
77 { | |
78 if (slice >= width_) | |
79 { | |
80 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
81 } | |
82 | |
11 | 83 std::auto_ptr<Orthanc::Image> result(new Orthanc::Image(format_, height_, depth_, false)); |
0 | 84 |
85 unsigned int bytesPerPixel = Orthanc::GetBytesPerPixel(format_); | |
86 | |
87 for (unsigned int z = 0; z < depth_; z++) | |
88 { | |
89 //uint8_t* target = reinterpret_cast<uint8_t*>(result->GetRow(depth_ - 1 - z)); | |
90 uint8_t* target = reinterpret_cast<uint8_t*>(result->GetRow(z)); | |
91 | |
92 for (unsigned int y = 0; y < height_; y++) | |
93 { | |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
94 const void* source = (reinterpret_cast<const uint8_t*>(image_.GetConstRow(y + z * height_)) + |
0 | 95 bytesPerPixel * slice); |
96 | |
97 memcpy(target, source, bytesPerPixel); | |
98 target += bytesPerPixel; | |
99 } | |
100 } | |
101 | |
102 return result.release(); | |
103 } | |
104 | |
105 | |
106 ImageBuffer3D::ImageBuffer3D(Orthanc::PixelFormat format, | |
107 unsigned int width, | |
108 unsigned int height, | |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
109 unsigned int depth, |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
110 bool computeRange) : |
11 | 111 image_(format, width, height * depth, false), |
0 | 112 format_(format), |
113 width_(width), | |
114 height_(height), | |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
115 depth_(depth), |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
116 computeRange_(computeRange), |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
117 hasRange_(false) |
0 | 118 { |
158
a053ca7fa5c6
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
119 LinearAlgebra::AssignVector(voxelDimensions_, 1, 1, 1); |
105 | 120 |
121 LOG(INFO) << "Created an image of " | |
122 << (GetEstimatedMemorySize() / (1024ll * 1024ll)) << "MB"; | |
0 | 123 } |
124 | |
125 | |
126 void ImageBuffer3D::Clear() | |
127 { | |
87
4a541cd4fa83
OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
128 memset(image_.GetBuffer(), 0, image_.GetHeight() * image_.GetPitch()); |
0 | 129 } |
130 | |
131 | |
110
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
105
diff
changeset
|
132 void ImageBuffer3D::SetAxialGeometry(const CoordinateSystem3D& geometry) |
0 | 133 { |
134 axialGeometry_ = geometry; | |
135 } | |
136 | |
137 | |
138 void ImageBuffer3D::SetVoxelDimensions(double x, | |
139 double y, | |
140 double z) | |
141 { | |
142 if (x <= 0 || | |
143 y <= 0 || | |
144 z <= 0) | |
145 { | |
146 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
147 } | |
148 | |
149 { | |
158
a053ca7fa5c6
LinearAlgebra toolbox
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
150 LinearAlgebra::AssignVector(voxelDimensions_, x, y, z); |
0 | 151 } |
152 } | |
153 | |
154 | |
139
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
155 Vector ImageBuffer3D::GetVoxelDimensions(VolumeProjection projection) const |
0 | 156 { |
157 Vector result; | |
158 switch (projection) | |
159 { | |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
160 case VolumeProjection_Axial: |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
161 result = voxelDimensions_; |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
162 break; |
0 | 163 |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
164 case VolumeProjection_Coronal: |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
165 LinearAlgebra::AssignVector(result, voxelDimensions_[0], voxelDimensions_[2], voxelDimensions_[1]); |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
166 break; |
0 | 167 |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
168 case VolumeProjection_Sagittal: |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
169 LinearAlgebra::AssignVector(result, voxelDimensions_[1], voxelDimensions_[2], voxelDimensions_[0]); |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
170 break; |
0 | 171 |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
172 default: |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
173 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
0 | 174 } |
175 | |
176 return result; | |
177 } | |
178 | |
179 | |
180 void ImageBuffer3D::GetSliceSize(unsigned int& width, | |
181 unsigned int& height, | |
182 VolumeProjection projection) | |
183 { | |
184 switch (projection) | |
185 { | |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
186 case VolumeProjection_Axial: |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
187 width = width_; |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
188 height = height_; |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
189 break; |
0 | 190 |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
191 case VolumeProjection_Coronal: |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
192 width = width_; |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
193 height = depth_; |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
194 break; |
0 | 195 |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
196 case VolumeProjection_Sagittal: |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
197 width = height_; |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
198 height = depth_; |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
199 break; |
0 | 200 |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
201 default: |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
202 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
0 | 203 } |
204 } | |
205 | |
206 | |
139
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
207 ParallelSlices* ImageBuffer3D::GetGeometry(VolumeProjection projection) const |
0 | 208 { |
209 std::auto_ptr<ParallelSlices> result(new ParallelSlices); | |
210 | |
211 switch (projection) | |
212 { | |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
213 case VolumeProjection_Axial: |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
214 for (unsigned int z = 0; z < depth_; z++) |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
215 { |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
216 Vector origin = axialGeometry_.GetOrigin(); |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
217 origin += static_cast<double>(z) * voxelDimensions_[2] * axialGeometry_.GetNormal(); |
0 | 218 |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
219 result->AddSlice(origin, |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
220 axialGeometry_.GetAxisX(), |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
221 axialGeometry_.GetAxisY()); |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
222 } |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
223 break; |
0 | 224 |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
225 case VolumeProjection_Coronal: |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
226 for (unsigned int y = 0; y < height_; y++) |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
227 { |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
228 Vector origin = axialGeometry_.GetOrigin(); |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
229 origin += static_cast<double>(y) * voxelDimensions_[1] * axialGeometry_.GetAxisY(); |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
230 origin += static_cast<double>(depth_ - 1) * voxelDimensions_[2] * axialGeometry_.GetNormal(); |
0 | 231 |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
232 result->AddSlice(origin, |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
233 axialGeometry_.GetAxisX(), |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
234 -axialGeometry_.GetNormal()); |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
235 } |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
236 break; |
0 | 237 |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
238 case VolumeProjection_Sagittal: |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
239 for (unsigned int x = 0; x < width_; x++) |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
240 { |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
241 Vector origin = axialGeometry_.GetOrigin(); |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
242 origin += static_cast<double>(x) * voxelDimensions_[0] * axialGeometry_.GetAxisX(); |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
243 origin += static_cast<double>(depth_ - 1) * voxelDimensions_[2] * axialGeometry_.GetNormal(); |
0 | 244 |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
245 result->AddSlice(origin, |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
246 axialGeometry_.GetAxisY(), |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
247 -axialGeometry_.GetNormal()); |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
248 } |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
249 break; |
0 | 250 |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
251 default: |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
252 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
0 | 253 } |
254 | |
255 return result.release(); | |
256 } | |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
257 |
0 | 258 |
105 | 259 uint64_t ImageBuffer3D::GetEstimatedMemorySize() const |
260 { | |
261 return image_.GetPitch() * image_.GetHeight() * Orthanc::GetBytesPerPixel(format_); | |
262 } | |
263 | |
264 | |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
265 void ImageBuffer3D::ExtendImageRange(const Orthanc::ImageAccessor& slice) |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
266 { |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
267 if (!computeRange_ || |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
268 slice.GetWidth() == 0 || |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
269 slice.GetHeight() == 0) |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
270 { |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
271 return; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
272 } |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
273 |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
274 float sliceMin, sliceMax; |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
275 |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
276 switch (slice.GetFormat()) |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
277 { |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
278 case Orthanc::PixelFormat_Grayscale8: |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
279 case Orthanc::PixelFormat_Grayscale16: |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
280 case Orthanc::PixelFormat_Grayscale32: |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
281 case Orthanc::PixelFormat_SignedGrayscale16: |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
282 { |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
283 int64_t a, b; |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
284 Orthanc::ImageProcessing::GetMinMaxIntegerValue(a, b, slice); |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
285 sliceMin = static_cast<float>(a); |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
286 sliceMax = static_cast<float>(b); |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
287 break; |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
288 } |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
289 |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
290 case Orthanc::PixelFormat_Float32: |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
291 Orthanc::ImageProcessing::GetMinMaxFloatValue(sliceMin, sliceMax, slice); |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
292 break; |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
293 |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
294 default: |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
295 return; |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
296 } |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
297 |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
298 if (hasRange_) |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
299 { |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
300 minValue_ = std::min(minValue_, sliceMin); |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
301 maxValue_ = std::max(maxValue_, sliceMax); |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
302 } |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
303 else |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
304 { |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
305 hasRange_ = true; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
306 minValue_ = sliceMin; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
307 maxValue_ = sliceMax; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
308 } |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
309 } |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
310 |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
311 |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
312 bool ImageBuffer3D::GetRange(float& minValue, |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
313 float& maxValue) const |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
314 { |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
315 if (hasRange_) |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
316 { |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
317 minValue = minValue_; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
318 maxValue = maxValue_; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
319 return true; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
320 } |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
321 else |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
322 { |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
323 return false; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
324 } |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
325 } |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
326 |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
327 |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
328 bool ImageBuffer3D::FitWindowingToRange(RenderStyle& style, |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
329 const DicomFrameConverter& converter) const |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
330 { |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
331 if (hasRange_) |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
332 { |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
333 style.windowing_ = ImageWindowing_Custom; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
334 style.customWindowCenter_ = converter.Apply((minValue_ + maxValue_) / 2.0); |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
335 style.customWindowWidth_ = converter.Apply(maxValue_ - minValue_); |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
336 |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
337 if (style.customWindowWidth_ > 1) |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
338 { |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
339 return true; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
340 } |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
341 } |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
342 |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
343 style.windowing_ = ImageWindowing_Custom; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
344 style.customWindowCenter_ = 128.0; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
345 style.customWindowWidth_ = 256.0; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
346 return false; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
347 } |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
348 |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
349 |
192
371da7fe2c0e
FiniteProjectiveCamera::ApplyRaytracer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
350 ImageBuffer3D::SliceReader::SliceReader(const ImageBuffer3D& that, |
0 | 351 VolumeProjection projection, |
87
4a541cd4fa83
OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
352 unsigned int slice) |
0 | 353 { |
354 switch (projection) | |
355 { | |
356 case VolumeProjection_Axial: | |
316
ce48c3b3b0e9
fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
357 that.GetAxialSliceAccessor(accessor_, slice, true); |
0 | 358 break; |
359 | |
360 case VolumeProjection_Coronal: | |
316
ce48c3b3b0e9
fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
361 that.GetCoronalSliceAccessor(accessor_, slice, true); |
0 | 362 break; |
363 | |
364 case VolumeProjection_Sagittal: | |
365 sagittal_.reset(that.ExtractSagittalSlice(slice)); | |
316
ce48c3b3b0e9
fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
366 sagittal_->GetReadOnlyAccessor(accessor_); |
0 | 367 break; |
368 | |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
369 default: |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
370 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
0 | 371 } |
372 } | |
373 | |
374 | |
375 void ImageBuffer3D::SliceWriter::Flush() | |
376 { | |
87
4a541cd4fa83
OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
377 if (modified_) |
0 | 378 { |
87
4a541cd4fa83
OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
379 if (sagittal_.get() != NULL) |
4a541cd4fa83
OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
380 { |
4a541cd4fa83
OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
381 // TODO |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
382 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
87
4a541cd4fa83
OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
383 } |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
384 |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
385 // Update the dynamic range of the underlying image, if |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
386 // "computeRange_" is set to true |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
387 that_.ExtendImageRange(accessor_); |
0 | 388 } |
389 } | |
390 | |
391 | |
392 ImageBuffer3D::SliceWriter::SliceWriter(ImageBuffer3D& that, | |
393 VolumeProjection projection, | |
394 unsigned int slice) : | |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
395 that_(that), |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
396 modified_(false) |
0 | 397 { |
398 switch (projection) | |
399 { | |
400 case VolumeProjection_Axial: | |
316
ce48c3b3b0e9
fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
401 that.GetAxialSliceAccessor(accessor_, slice, false); |
0 | 402 break; |
403 | |
404 case VolumeProjection_Coronal: | |
316
ce48c3b3b0e9
fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
405 that.GetCoronalSliceAccessor(accessor_, slice, false); |
0 | 406 break; |
407 | |
408 case VolumeProjection_Sagittal: | |
409 sagittal_.reset(that.ExtractSagittalSlice(slice)); | |
316
ce48c3b3b0e9
fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
410 sagittal_->GetWriteableAccessor(accessor_); |
0 | 411 break; |
412 | |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
413 default: |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
414 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
0 | 415 } |
416 } | |
139
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
417 |
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
418 |
143 | 419 uint8_t ImageBuffer3D::GetVoxelGrayscale8(unsigned int x, |
141
88bca952cb17
ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
139
diff
changeset
|
420 unsigned int y, |
88bca952cb17
ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
139
diff
changeset
|
421 unsigned int z) const |
88bca952cb17
ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
139
diff
changeset
|
422 { |
88bca952cb17
ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
139
diff
changeset
|
423 if (format_ != Orthanc::PixelFormat_Grayscale8) |
88bca952cb17
ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
139
diff
changeset
|
424 { |
88bca952cb17
ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
139
diff
changeset
|
425 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat); |
88bca952cb17
ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
139
diff
changeset
|
426 } |
88bca952cb17
ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
139
diff
changeset
|
427 |
88bca952cb17
ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
139
diff
changeset
|
428 if (x >= width_ || |
88bca952cb17
ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
139
diff
changeset
|
429 y >= height_ || |
88bca952cb17
ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
139
diff
changeset
|
430 z >= depth_) |
88bca952cb17
ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
139
diff
changeset
|
431 { |
88bca952cb17
ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
139
diff
changeset
|
432 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
88bca952cb17
ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
139
diff
changeset
|
433 } |
88bca952cb17
ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
139
diff
changeset
|
434 |
88bca952cb17
ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
139
diff
changeset
|
435 const void* p = image_.GetConstRow(y + height_ * (depth_ - 1 - z)); |
88bca952cb17
ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
139
diff
changeset
|
436 return reinterpret_cast<const uint8_t*>(p) [x]; |
88bca952cb17
ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
139
diff
changeset
|
437 } |
88bca952cb17
ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
139
diff
changeset
|
438 |
88bca952cb17
ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
139
diff
changeset
|
439 |
143 | 440 uint16_t ImageBuffer3D::GetVoxelGrayscale16(unsigned int x, |
139
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
441 unsigned int y, |
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
442 unsigned int z) const |
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
443 { |
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
444 if (format_ != Orthanc::PixelFormat_Grayscale16) |
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
445 { |
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
446 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat); |
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
447 } |
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
448 |
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
449 if (x >= width_ || |
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
450 y >= height_ || |
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
451 z >= depth_) |
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
452 { |
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
453 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
454 } |
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
455 |
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
456 const void* p = image_.GetConstRow(y + height_ * (depth_ - 1 - z)); |
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
457 return reinterpret_cast<const uint16_t*>(p) [x]; |
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
458 } |
187
a12ca0f4aaaa
ImageBuffer3D::GetCoordinates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
459 |
a12ca0f4aaaa
ImageBuffer3D::GetCoordinates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
460 |
a12ca0f4aaaa
ImageBuffer3D::GetCoordinates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
461 Vector ImageBuffer3D::GetCoordinates(float x, |
a12ca0f4aaaa
ImageBuffer3D::GetCoordinates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
462 float y, |
a12ca0f4aaaa
ImageBuffer3D::GetCoordinates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
463 float z) const |
a12ca0f4aaaa
ImageBuffer3D::GetCoordinates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
464 { |
a12ca0f4aaaa
ImageBuffer3D::GetCoordinates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
465 Vector ps = GetVoxelDimensions(OrthancStone::VolumeProjection_Axial); |
a12ca0f4aaaa
ImageBuffer3D::GetCoordinates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
466 |
a12ca0f4aaaa
ImageBuffer3D::GetCoordinates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
467 const CoordinateSystem3D& axial = GetAxialGeometry(); |
a12ca0f4aaaa
ImageBuffer3D::GetCoordinates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
468 |
a12ca0f4aaaa
ImageBuffer3D::GetCoordinates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
469 Vector origin = (axial.MapSliceToWorldCoordinates(-0.5 * ps[0], -0.5 * ps[1]) - |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
470 0.5 * ps[2] * axial.GetNormal()); |
187
a12ca0f4aaaa
ImageBuffer3D::GetCoordinates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
471 |
a12ca0f4aaaa
ImageBuffer3D::GetCoordinates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
472 return (origin + |
a12ca0f4aaaa
ImageBuffer3D::GetCoordinates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
473 axial.GetAxisX() * ps[0] * x * static_cast<double>(GetWidth()) + |
318
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
474 axial.GetAxisY() * ps[1] * y * static_cast<double>(GetHeight()) + |
3a4ca166fafa
ImageAccessor refactoring + implemented Image Cache in SmartLoader
am@osimis.io
parents:
212
diff
changeset
|
475 axial.GetNormal() * ps[2] * z * static_cast<double>(GetDepth())); |
187
a12ca0f4aaaa
ImageBuffer3D::GetCoordinates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
158
diff
changeset
|
476 } |
0 | 477 } |