Mercurial > hg > orthanc-stone
annotate Framework/Volumes/ImageBuffer3D.h @ 261:58ad26032bd6 am-2
removed unused file
author | am@osimis.io |
---|---|
date | Tue, 17 Jul 2018 14:44:26 +0200 |
parents | 5412adf19980 |
children | ce48c3b3b0e9 3a4ca166fafa |
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 | |
134
4cff7b1ed31d
upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
5 * Copyright (C) 2017-2018 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. | |
16 * | |
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 #pragma once | |
23 | |
194
7a031ac16b2d
rename Enumerations.h to StoneEnumerations.h to avoid clashes with Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
192
diff
changeset
|
24 #include "../StoneEnumerations.h" |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
25 #include "../Layers/RenderStyle.h" |
110
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
105
diff
changeset
|
26 #include "../Toolbox/CoordinateSystem3D.h" |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
27 #include "../Toolbox/DicomFrameConverter.h" |
0 | 28 #include "../Toolbox/ParallelSlices.h" |
29 | |
212
5412adf19980
resort to OrthancFramework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
201
diff
changeset
|
30 #include <Core/Images/Image.h> |
0 | 31 |
32 namespace OrthancStone | |
33 { | |
53
c2dc924f1a63
removing threading out of the framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
47
diff
changeset
|
34 class ImageBuffer3D : public boost::noncopyable |
0 | 35 { |
36 private: | |
110
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
105
diff
changeset
|
37 CoordinateSystem3D axialGeometry_; |
0 | 38 Vector voxelDimensions_; |
39 Orthanc::Image image_; | |
40 Orthanc::PixelFormat format_; | |
41 unsigned int width_; | |
42 unsigned int height_; | |
43 unsigned int depth_; | |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
44 bool computeRange_; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
45 bool hasRange_; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
46 float minValue_; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
47 float maxValue_; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
48 |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
49 void ExtendImageRange(const Orthanc::ImageAccessor& slice); |
0 | 50 |
51 Orthanc::ImageAccessor GetAxialSliceAccessor(unsigned int slice, | |
192
371da7fe2c0e
FiniteProjectiveCamera::ApplyRaytracer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
52 bool readOnly) const; |
0 | 53 |
54 Orthanc::ImageAccessor GetCoronalSliceAccessor(unsigned int slice, | |
192
371da7fe2c0e
FiniteProjectiveCamera::ApplyRaytracer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
55 bool readOnly) const; |
0 | 56 |
57 Orthanc::Image* ExtractSagittalSlice(unsigned int slice) const; | |
58 | |
143 | 59 template <typename T> |
60 T GetPixelUnchecked(unsigned int x, | |
61 unsigned int y, | |
62 unsigned int z) const | |
63 { | |
64 const uint8_t* buffer = reinterpret_cast<const uint8_t*>(image_.GetConstBuffer()); | |
65 const uint8_t* row = buffer + (y + height_ * (depth_ - 1 - z)) * image_.GetPitch(); | |
66 return reinterpret_cast<const T*>(row) [x]; | |
67 } | |
68 | |
0 | 69 public: |
70 ImageBuffer3D(Orthanc::PixelFormat format, | |
71 unsigned int width, | |
72 unsigned int height, | |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
73 unsigned int depth, |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
74 bool computeRange); |
0 | 75 |
76 void Clear(); | |
77 | |
78 // Set the geometry of the first axial slice (i.e. the one whose | |
79 // depth == 0) | |
110
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
105
diff
changeset
|
80 void SetAxialGeometry(const CoordinateSystem3D& geometry); |
0 | 81 |
139
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
82 const CoordinateSystem3D& GetAxialGeometry() const |
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
83 { |
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
84 return axialGeometry_; |
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
85 } |
0 | 86 |
87 void SetVoxelDimensions(double x, | |
88 double y, | |
89 double z); | |
90 | |
139
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
91 Vector GetVoxelDimensions(VolumeProjection projection) const; |
0 | 92 |
93 void GetSliceSize(unsigned int& width, | |
94 unsigned int& height, | |
95 VolumeProjection projection); | |
96 | |
179
db21c1810c89
moving PixelTraits to the Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
149
diff
changeset
|
97 const Orthanc::ImageAccessor& GetInternalImage() const |
db21c1810c89
moving PixelTraits to the Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
149
diff
changeset
|
98 { |
db21c1810c89
moving PixelTraits to the Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
149
diff
changeset
|
99 return image_; |
db21c1810c89
moving PixelTraits to the Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
149
diff
changeset
|
100 } |
db21c1810c89
moving PixelTraits to the Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
149
diff
changeset
|
101 |
0 | 102 unsigned int GetWidth() const |
103 { | |
104 return width_; | |
105 } | |
106 | |
107 unsigned int GetHeight() const | |
108 { | |
109 return height_; | |
110 } | |
111 | |
112 unsigned int GetDepth() const | |
113 { | |
114 return depth_; | |
115 } | |
116 | |
117 Orthanc::PixelFormat GetFormat() const | |
118 { | |
119 return format_; | |
120 } | |
121 | |
139
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
122 ParallelSlices* GetGeometry(VolumeProjection projection) const; |
0 | 123 |
105 | 124 uint64_t GetEstimatedMemorySize() const; |
125 | |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
126 bool GetRange(float& minValue, |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
127 float& maxValue) const; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
128 |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
129 bool FitWindowingToRange(RenderStyle& style, |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
130 const DicomFrameConverter& converter) const; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
131 |
143 | 132 uint8_t GetVoxelGrayscale8Unchecked(unsigned int x, |
133 unsigned int y, | |
134 unsigned int z) const | |
135 { | |
136 return GetPixelUnchecked<uint8_t>(x, y, z); | |
137 } | |
138 | |
139 uint16_t GetVoxelGrayscale16Unchecked(unsigned int x, | |
140 unsigned int y, | |
141 unsigned int z) const | |
142 { | |
143 return GetPixelUnchecked<uint16_t>(x, y, z); | |
144 } | |
145 | |
149
f7be90de6d1b
ImageBuffer3D::GetVoxelSignedGrayscale16Unchecked()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
146 int16_t GetVoxelSignedGrayscale16Unchecked(unsigned int x, |
f7be90de6d1b
ImageBuffer3D::GetVoxelSignedGrayscale16Unchecked()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
147 unsigned int y, |
f7be90de6d1b
ImageBuffer3D::GetVoxelSignedGrayscale16Unchecked()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
148 unsigned int z) const |
f7be90de6d1b
ImageBuffer3D::GetVoxelSignedGrayscale16Unchecked()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
149 { |
f7be90de6d1b
ImageBuffer3D::GetVoxelSignedGrayscale16Unchecked()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
150 return GetPixelUnchecked<int16_t>(x, y, z); |
f7be90de6d1b
ImageBuffer3D::GetVoxelSignedGrayscale16Unchecked()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
151 } |
f7be90de6d1b
ImageBuffer3D::GetVoxelSignedGrayscale16Unchecked()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
143
diff
changeset
|
152 |
143 | 153 uint8_t GetVoxelGrayscale8(unsigned int x, |
141
88bca952cb17
ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
139
diff
changeset
|
154 unsigned int y, |
88bca952cb17
ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
139
diff
changeset
|
155 unsigned int z) const; |
88bca952cb17
ImageBuffer3D::GetPixelGrayscale8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
139
diff
changeset
|
156 |
143 | 157 uint16_t GetVoxelGrayscale16(unsigned int x, |
139
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
158 unsigned int y, |
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
159 unsigned int z) const; |
22628d37ef5c
ImageBuffer3D::GetPixelGrayscale16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
135
diff
changeset
|
160 |
187
a12ca0f4aaaa
ImageBuffer3D::GetCoordinates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
161 // Get the 3D position of a point in the volume, where x, y and z |
a12ca0f4aaaa
ImageBuffer3D::GetCoordinates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
162 // lie in the [0;1] range |
a12ca0f4aaaa
ImageBuffer3D::GetCoordinates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
163 Vector GetCoordinates(float x, |
a12ca0f4aaaa
ImageBuffer3D::GetCoordinates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
164 float y, |
a12ca0f4aaaa
ImageBuffer3D::GetCoordinates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
165 float z) const; |
a12ca0f4aaaa
ImageBuffer3D::GetCoordinates
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
166 |
0 | 167 |
168 class SliceReader : public boost::noncopyable | |
169 { | |
170 private: | |
171 Orthanc::ImageAccessor accessor_; | |
172 std::auto_ptr<Orthanc::Image> sagittal_; // Unused for axial and coronal | |
173 | |
174 public: | |
192
371da7fe2c0e
FiniteProjectiveCamera::ApplyRaytracer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
187
diff
changeset
|
175 SliceReader(const ImageBuffer3D& that, |
0 | 176 VolumeProjection projection, |
177 unsigned int slice); | |
178 | |
179 const Orthanc::ImageAccessor& GetAccessor() const | |
180 { | |
181 return accessor_; | |
182 } | |
183 }; | |
184 | |
185 | |
186 class SliceWriter : public boost::noncopyable | |
187 { | |
188 private: | |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
113
diff
changeset
|
189 ImageBuffer3D& that_; |
87
4a541cd4fa83
OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
190 bool modified_; |
0 | 191 Orthanc::ImageAccessor accessor_; |
192 std::auto_ptr<Orthanc::Image> sagittal_; // Unused for axial and coronal | |
193 | |
194 void Flush(); | |
195 | |
196 public: | |
197 SliceWriter(ImageBuffer3D& that, | |
198 VolumeProjection projection, | |
199 unsigned int slice); | |
200 | |
201 ~SliceWriter() | |
202 { | |
203 Flush(); | |
204 } | |
205 | |
87
4a541cd4fa83
OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
206 const Orthanc::ImageAccessor& GetAccessor() const |
4a541cd4fa83
OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
207 { |
4a541cd4fa83
OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
208 return accessor_; |
4a541cd4fa83
OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
209 } |
4a541cd4fa83
OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
210 |
0 | 211 Orthanc::ImageAccessor& GetAccessor() |
212 { | |
87
4a541cd4fa83
OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
53
diff
changeset
|
213 modified_ = true; |
0 | 214 return accessor_; |
215 } | |
216 }; | |
217 }; | |
218 } |