Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Scene2D/GrayscaleStyleConfigurator.cpp @ 2043:f3d756e5503f deep-learning
fix build on wasm
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 10 Feb 2023 09:13:49 +0100 |
parents | 7053b8a0aaec |
children | 07964689cb0b |
rev | line source |
---|---|
814 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1871
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
814 | 7 * |
8 * 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
|
9 * modify it under the terms of the GNU Lesser General Public License |
814 | 10 * as published by the Free Software Foundation, either version 3 of |
11 * the License, or (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, but | |
14 * 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
|
15 * 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
|
16 * Lesser General Public License for more details. |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1571
diff
changeset
|
17 * |
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
|
18 * 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
|
19 * 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
|
20 * <http://www.gnu.org/licenses/>. |
814 | 21 **/ |
22 | |
23 | |
24 #include "GrayscaleStyleConfigurator.h" | |
25 | |
835
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
26 #include "FloatTextureSceneLayer.h" |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
27 |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1300
diff
changeset
|
28 #include <OrthancException.h> |
814 | 29 |
30 namespace OrthancStone | |
31 { | |
1179
177e7d431cd1
log scale in textures, remove redundant code for LUTs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1163
diff
changeset
|
32 GrayscaleStyleConfigurator::GrayscaleStyleConfigurator() : |
177e7d431cd1
log scale in textures, remove redundant code for LUTs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1163
diff
changeset
|
33 revision_(0), |
177e7d431cd1
log scale in textures, remove redundant code for LUTs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1163
diff
changeset
|
34 linearInterpolation_(false), |
1212 | 35 hasWindowingOverride_(false), |
1571 | 36 windowing_(ImageWindowing_Custom), |
1179
177e7d431cd1
log scale in textures, remove redundant code for LUTs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1163
diff
changeset
|
37 customWindowWidth_(0), |
177e7d431cd1
log scale in textures, remove redundant code for LUTs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1163
diff
changeset
|
38 customWindowCenter_(0), |
1212 | 39 hasInversionOverride_(false), |
1179
177e7d431cd1
log scale in textures, remove redundant code for LUTs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1163
diff
changeset
|
40 inverted_(false), |
177e7d431cd1
log scale in textures, remove redundant code for LUTs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1163
diff
changeset
|
41 applyLog_(false) |
177e7d431cd1
log scale in textures, remove redundant code for LUTs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1163
diff
changeset
|
42 { |
177e7d431cd1
log scale in textures, remove redundant code for LUTs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1163
diff
changeset
|
43 } |
177e7d431cd1
log scale in textures, remove redundant code for LUTs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1163
diff
changeset
|
44 |
836 | 45 void GrayscaleStyleConfigurator::SetWindowing(ImageWindowing windowing) |
46 { | |
1209
b5dec783ba08
Fixed the style configurator to only set inversion on the image if it has been
Benjamin Golinvaux <bgo@osimis.io>
parents:
1061
diff
changeset
|
47 hasWindowingOverride_ = true; |
836 | 48 windowing_ = windowing; |
49 revision_++; | |
50 } | |
51 | |
913
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
836
diff
changeset
|
52 void GrayscaleStyleConfigurator::SetCustomWindowing(float windowCenter, float windowWidth) |
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
836
diff
changeset
|
53 { |
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
836
diff
changeset
|
54 SetWindowing(ImageWindowing_Custom); |
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
836
diff
changeset
|
55 customWindowCenter_ = windowCenter; |
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
836
diff
changeset
|
56 customWindowWidth_ = windowWidth; |
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
836
diff
changeset
|
57 } |
836 | 58 |
1061
eb28dfe432f7
fixed typo in assert. msg. + getters for custom windowing in grayscale layer configurator.
Benjamin Golinvaux <bgo@osimis.io>
parents:
914
diff
changeset
|
59 void GrayscaleStyleConfigurator::GetCustomWindowing(float& windowCenter, float& windowWidth) const |
eb28dfe432f7
fixed typo in assert. msg. + getters for custom windowing in grayscale layer configurator.
Benjamin Golinvaux <bgo@osimis.io>
parents:
914
diff
changeset
|
60 { |
eb28dfe432f7
fixed typo in assert. msg. + getters for custom windowing in grayscale layer configurator.
Benjamin Golinvaux <bgo@osimis.io>
parents:
914
diff
changeset
|
61 windowCenter = customWindowCenter_; |
eb28dfe432f7
fixed typo in assert. msg. + getters for custom windowing in grayscale layer configurator.
Benjamin Golinvaux <bgo@osimis.io>
parents:
914
diff
changeset
|
62 windowWidth = customWindowWidth_; |
eb28dfe432f7
fixed typo in assert. msg. + getters for custom windowing in grayscale layer configurator.
Benjamin Golinvaux <bgo@osimis.io>
parents:
914
diff
changeset
|
63 } |
914
4d1f57773b5b
Added image inversion support in GrayscaleStyleConfigurator + OpenGLFloatTextureProgram
Benjamin Golinvaux <bgo@osimis.io>
parents:
913
diff
changeset
|
64 |
4d1f57773b5b
Added image inversion support in GrayscaleStyleConfigurator + OpenGLFloatTextureProgram
Benjamin Golinvaux <bgo@osimis.io>
parents:
913
diff
changeset
|
65 void GrayscaleStyleConfigurator::SetInverted(bool inverted) |
4d1f57773b5b
Added image inversion support in GrayscaleStyleConfigurator + OpenGLFloatTextureProgram
Benjamin Golinvaux <bgo@osimis.io>
parents:
913
diff
changeset
|
66 { |
1209
b5dec783ba08
Fixed the style configurator to only set inversion on the image if it has been
Benjamin Golinvaux <bgo@osimis.io>
parents:
1061
diff
changeset
|
67 hasInversionOverride_ = true; |
914
4d1f57773b5b
Added image inversion support in GrayscaleStyleConfigurator + OpenGLFloatTextureProgram
Benjamin Golinvaux <bgo@osimis.io>
parents:
913
diff
changeset
|
68 inverted_ = inverted; |
4d1f57773b5b
Added image inversion support in GrayscaleStyleConfigurator + OpenGLFloatTextureProgram
Benjamin Golinvaux <bgo@osimis.io>
parents:
913
diff
changeset
|
69 revision_++; |
4d1f57773b5b
Added image inversion support in GrayscaleStyleConfigurator + OpenGLFloatTextureProgram
Benjamin Golinvaux <bgo@osimis.io>
parents:
913
diff
changeset
|
70 } |
4d1f57773b5b
Added image inversion support in GrayscaleStyleConfigurator + OpenGLFloatTextureProgram
Benjamin Golinvaux <bgo@osimis.io>
parents:
913
diff
changeset
|
71 |
835
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
72 void GrayscaleStyleConfigurator::SetLinearInterpolation(bool enabled) |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
73 { |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
74 linearInterpolation_ = enabled; |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
75 revision_++; |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
76 } |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
77 |
1163 | 78 void GrayscaleStyleConfigurator::SetApplyLog(bool apply) |
79 { | |
80 applyLog_ = apply; | |
81 revision_++; | |
82 } | |
83 | |
835
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
84 TextureBaseSceneLayer* GrayscaleStyleConfigurator::CreateTextureFromImage( |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
85 const Orthanc::ImageAccessor& image) const |
814 | 86 { |
87 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | |
88 } | |
835
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
89 |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
90 TextureBaseSceneLayer* GrayscaleStyleConfigurator::CreateTextureFromDicom( |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
91 const Orthanc::ImageAccessor& frame, |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
92 const DicomInstanceParameters& parameters) const |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
93 { |
1298
8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
94 std::unique_ptr<TextureBaseSceneLayer> layer(parameters.CreateTexture(frame)); |
835
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
95 |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
96 if (layer.get() == NULL || |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
97 layer->GetTexture().GetFormat() != Orthanc::PixelFormat_Float32) |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
98 { |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
99 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat); |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
100 } |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
101 else |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
102 { |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
103 return layer.release(); |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
104 } |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
105 } |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
106 |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
107 void GrayscaleStyleConfigurator::ApplyStyle(ISceneLayer& layer) const |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
108 { |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
109 FloatTextureSceneLayer& l = dynamic_cast<FloatTextureSceneLayer&>(layer); |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
110 |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
111 l.SetLinearInterpolation(linearInterpolation_); |
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
112 |
1209
b5dec783ba08
Fixed the style configurator to only set inversion on the image if it has been
Benjamin Golinvaux <bgo@osimis.io>
parents:
1061
diff
changeset
|
113 if (hasWindowingOverride_) |
835
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
114 { |
913
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
836
diff
changeset
|
115 if (windowing_ != ImageWindowing_Custom) |
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
836
diff
changeset
|
116 { |
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
836
diff
changeset
|
117 l.SetWindowing(windowing_); |
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
836
diff
changeset
|
118 } |
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
836
diff
changeset
|
119 else |
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
836
diff
changeset
|
120 { |
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
836
diff
changeset
|
121 l.SetCustomWindowing(customWindowCenter_, customWindowWidth_); |
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
836
diff
changeset
|
122 } |
835
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
123 } |
1163 | 124 |
1209
b5dec783ba08
Fixed the style configurator to only set inversion on the image if it has been
Benjamin Golinvaux <bgo@osimis.io>
parents:
1061
diff
changeset
|
125 if (hasInversionOverride_) |
b5dec783ba08
Fixed the style configurator to only set inversion on the image if it has been
Benjamin Golinvaux <bgo@osimis.io>
parents:
1061
diff
changeset
|
126 { |
b5dec783ba08
Fixed the style configurator to only set inversion on the image if it has been
Benjamin Golinvaux <bgo@osimis.io>
parents:
1061
diff
changeset
|
127 l.SetInverted(inverted_); |
b5dec783ba08
Fixed the style configurator to only set inversion on the image if it has been
Benjamin Golinvaux <bgo@osimis.io>
parents:
1061
diff
changeset
|
128 } |
1212 | 129 |
1163 | 130 l.SetApplyLog(applyLog_); |
835
0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
131 } |
814 | 132 } |