Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Scene2D/FloatTextureSceneLayer.cpp @ 1533:82279abb92d0
GrayscaleWindowingSceneTracker
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 07 Aug 2020 15:55:59 +0200 |
parents | 244ad1e4e76a |
children | 4fb8fdf03314 |
comparison
equal
deleted
inserted
replaced
1532:c7a37c3a0b8e | 1533:82279abb92d0 |
---|---|
29 | 29 |
30 namespace OrthancStone | 30 namespace OrthancStone |
31 { | 31 { |
32 FloatTextureSceneLayer::FloatTextureSceneLayer(const Orthanc::ImageAccessor& texture) : | 32 FloatTextureSceneLayer::FloatTextureSceneLayer(const Orthanc::ImageAccessor& texture) : |
33 inverted_(false), | 33 inverted_(false), |
34 applyLog_(false) | 34 applyLog_(false), |
35 isRangeComputed_(false), | |
36 minValue_(0), | |
37 maxValue_(0) | |
35 { | 38 { |
36 { | 39 { |
37 std::unique_ptr<Orthanc::ImageAccessor> t( | 40 std::unique_ptr<Orthanc::ImageAccessor> t( |
38 new Orthanc::Image(Orthanc::PixelFormat_Float32, | 41 new Orthanc::Image(Orthanc::PixelFormat_Float32, |
39 texture.GetWidth(), | 42 texture.GetWidth(), |
105 | 108 |
106 | 109 |
107 void FloatTextureSceneLayer::FitRange() | 110 void FloatTextureSceneLayer::FitRange() |
108 { | 111 { |
109 float minValue, maxValue; | 112 float minValue, maxValue; |
110 Orthanc::ImageProcessing::GetMinMaxFloatValue(minValue, maxValue, GetTexture()); | 113 GetRange(minValue, maxValue); |
114 assert(minValue <= maxValue); | |
111 | 115 |
112 float width; | 116 float width; |
113 | 117 |
114 assert(minValue <= maxValue); | |
115 if (LinearAlgebra::IsCloseToZero(maxValue - minValue)) | 118 if (LinearAlgebra::IsCloseToZero(maxValue - minValue)) |
116 { | 119 { |
117 width = 1; | 120 width = 1; |
118 } | 121 } |
119 else | 122 else |
123 | 126 |
124 SetCustomWindowing((minValue + maxValue) / 2.0f, width); | 127 SetCustomWindowing((minValue + maxValue) / 2.0f, width); |
125 } | 128 } |
126 | 129 |
127 | 130 |
131 void FloatTextureSceneLayer::GetRange(float& minValue, | |
132 float& maxValue) | |
133 { | |
134 if (!isRangeComputed_) | |
135 { | |
136 Orthanc::ImageProcessing::GetMinMaxFloatValue(minValue_, maxValue_, GetTexture()); | |
137 isRangeComputed_ = true; | |
138 } | |
139 | |
140 assert(minValue_ <= maxValue_); | |
141 | |
142 minValue = minValue_; | |
143 maxValue = maxValue_; | |
144 } | |
145 | |
146 | |
128 ISceneLayer* FloatTextureSceneLayer::Clone() const | 147 ISceneLayer* FloatTextureSceneLayer::Clone() const |
129 { | 148 { |
130 std::unique_ptr<FloatTextureSceneLayer> cloned | 149 std::unique_ptr<FloatTextureSceneLayer> cloned |
131 (new FloatTextureSceneLayer(GetTexture())); | 150 (new FloatTextureSceneLayer(GetTexture())); |
132 | 151 |
134 cloned->windowing_ = windowing_; | 153 cloned->windowing_ = windowing_; |
135 cloned->customCenter_ = customCenter_; | 154 cloned->customCenter_ = customCenter_; |
136 cloned->customWidth_ = customWidth_; | 155 cloned->customWidth_ = customWidth_; |
137 cloned->inverted_ = inverted_; | 156 cloned->inverted_ = inverted_; |
138 cloned->applyLog_ = applyLog_; | 157 cloned->applyLog_ = applyLog_; |
158 cloned->isRangeComputed_ = isRangeComputed_; | |
159 cloned->minValue_ = minValue_; | |
160 cloned->maxValue_ = maxValue_; | |
139 | 161 |
140 return cloned.release(); | 162 return cloned.release(); |
141 } | 163 } |
142 } | 164 } |