Mercurial > hg > orthanc-stone
annotate Framework/Volumes/VolumeReslicer.h @ 981:c20dbaab360c
Ability to cope with empty "Referenced SOP Instance UID" (dicom path (3006,0039)[i] / (0x3006, 0x0040)[0] / (0x3006, 0x0016)[0] / (0x0008, 0x1155)) + better logs + code formating
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Fri, 06 Sep 2019 09:38:18 +0200 |
parents | cd13a062c9bd |
children | 2d8ab34c8c91 |
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 #pragma once |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
154 | 24 #include "../Toolbox/Extent2D.h" |
742
fa5febe0f0c2
moved OrientedBoundingBox in the Volumes folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
735
diff
changeset
|
25 #include "OrientedVolumeBoundingBox.h" |
154 | 26 #include "ImageBuffer3D.h" |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 namespace OrthancStone |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 // Hypothesis: The output voxels always have square size |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 class VolumeReslicer : public boost::noncopyable |
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 private: |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 // Input parameters |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 Orthanc::PixelFormat outputFormat_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 bool hasLinearFunction_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 float scaling_; // "a" in "f(x) = a * x + b" |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 float offset_; // "b" in "f(x) = a * x + b" |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 ImageInterpolation interpolation_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 bool fastMode_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 // Output of reslicing |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 bool success_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 Extent2D extent_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 std::auto_ptr<Orthanc::Image> slice_; |
783 | 46 double pixelSpacing_; |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 void CheckIterators(const ImageBuffer3D& source, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 const CoordinateSystem3D& plane, |
742
fa5febe0f0c2
moved OrientedBoundingBox in the Volumes folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
735
diff
changeset
|
50 const OrientedVolumeBoundingBox& box) const; |
153
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 void Reset(); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 float GetMinOutputValue() const; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 float GetMaxOutputValue() const; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 void SetWindow(float low, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 float high); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 public: |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 VolumeReslicer(); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 void GetLinearFunction(float& scaling, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 float& offset) const; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 void ResetLinearFunction(); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 void SetLinearFunction(float scaling, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 float offset); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 void FitRange(const ImageBuffer3D& image); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 void SetWindowing(ImageWindowing windowing, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 const ImageBuffer3D& image, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 float rescaleSlope, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 float rescaleIntercept); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 Orthanc::PixelFormat GetOutputFormat() const |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 return outputFormat_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 } |
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 void SetOutputFormat(Orthanc::PixelFormat format); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 ImageInterpolation GetInterpolation() const |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 return interpolation_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 } |
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 void SetInterpolation(ImageInterpolation interpolation); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 bool IsFastMode() const |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 return fastMode_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 } |
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 void EnableFastMode(bool enabled) |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 fastMode_ = enabled; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 } |
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 bool IsSuccess() const |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 { |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 return success_; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 } |
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 const Extent2D& GetOutputExtent() const; |
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 const Orthanc::ImageAccessor& GetOutputSlice() const; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 Orthanc::ImageAccessor* ReleaseOutputSlice(); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 void Apply(const ImageBuffer3D& source, |
735
c3bbb130abc4
removing dependencies in ImageBuffer3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
115 const VolumeImageGeometry& geometry, |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 const CoordinateSystem3D& plane); |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 void Apply(const ImageBuffer3D& source, |
735
c3bbb130abc4
removing dependencies in ImageBuffer3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
119 const VolumeImageGeometry& geometry, |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 const CoordinateSystem3D& plane, |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 double voxelSize); |
783 | 122 |
123 double GetPixelSpacing() const; | |
153
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 }; |
ae531ab5dcd9
new class: VolumeReslicer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 } |