Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Volumes/VolumeReslicer.h @ 1598:8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 26 Oct 2020 20:49:28 +0100 |
parents | 4fb8fdf03314 |
children | 9ac2a65d4172 |
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 | |
1270
2d8ab34c8c91
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
783
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
186 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
186 | 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 | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
15 * Lesser General Public License for more details. |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
16 * |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
18 * License along with this program. If not, see |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
186 | 20 **/ |
21 | |
22 | |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 #pragma once |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 |
154 | 25 #include "../Toolbox/Extent2D.h" |
742
fa5febe0f0c2
moved OrientedBoundingBox in the Volumes folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
735
diff
changeset
|
26 #include "OrientedVolumeBoundingBox.h" |
154 | 27 #include "ImageBuffer3D.h" |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 namespace OrthancStone |
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 // Hypothesis: The output voxels always have square size |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 class VolumeReslicer : public boost::noncopyable |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 private: |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 // Input parameters |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 Orthanc::PixelFormat outputFormat_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 bool hasLinearFunction_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 float scaling_; // "a" in "f(x) = a * x + b" |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 float offset_; // "b" in "f(x) = a * x + b" |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 ImageInterpolation interpolation_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 bool fastMode_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 // Output of reslicing |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 bool success_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 Extent2D extent_; |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
46 std::unique_ptr<Orthanc::Image> slice_; |
783 | 47 double pixelSpacing_; |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 void CheckIterators(const ImageBuffer3D& source, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 const CoordinateSystem3D& plane, |
742
fa5febe0f0c2
moved OrientedBoundingBox in the Volumes folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
735
diff
changeset
|
51 const OrientedVolumeBoundingBox& box) const; |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
52 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 void Reset(); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 float GetMinOutputValue() const; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 float GetMaxOutputValue() const; |
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 void SetWindow(float low, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 float high); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 public: |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 VolumeReslicer(); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 void GetLinearFunction(float& scaling, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 float& offset) const; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 void ResetLinearFunction(); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 void SetLinearFunction(float scaling, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 float offset); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 void FitRange(const ImageBuffer3D& image); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 void SetWindowing(ImageWindowing windowing, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 const ImageBuffer3D& image, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 float rescaleSlope, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 float rescaleIntercept); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 Orthanc::PixelFormat GetOutputFormat() const |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 return outputFormat_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 void SetOutputFormat(Orthanc::PixelFormat format); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 ImageInterpolation GetInterpolation() const |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 return interpolation_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 void SetInterpolation(ImageInterpolation interpolation); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 bool IsFastMode() const |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 return fastMode_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 void EnableFastMode(bool enabled) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 fastMode_ = enabled; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 } |
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 bool IsSuccess() const |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 return success_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 } |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 const Extent2D& GetOutputExtent() const; |
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 const Orthanc::ImageAccessor& GetOutputSlice() const; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 Orthanc::ImageAccessor* ReleaseOutputSlice(); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 void Apply(const ImageBuffer3D& source, |
735
c3bbb130abc4
removing dependencies in ImageBuffer3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
116 const VolumeImageGeometry& geometry, |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 const CoordinateSystem3D& plane); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 void Apply(const ImageBuffer3D& source, |
735
c3bbb130abc4
removing dependencies in ImageBuffer3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
120 const VolumeImageGeometry& geometry, |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 const CoordinateSystem3D& plane, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 double voxelSize); |
783 | 123 |
124 double GetPixelSpacing() const; | |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 }; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 } |