comparison Framework/Scene2D/LookupTableTextureSceneLayer.cpp @ 1083:f72d1ab42932 broker

integration mainline->broker
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 22 Oct 2019 13:14:05 +0200
parents 369050c846a9
children 640feb146fa8
comparison
equal deleted inserted replaced
1079:e6d2ff8f1ab4 1083:f72d1ab42932
25 #include <Core/Images/ImageProcessing.h> 25 #include <Core/Images/ImageProcessing.h>
26 #include <Core/OrthancException.h> 26 #include <Core/OrthancException.h>
27 27
28 namespace OrthancStone 28 namespace OrthancStone
29 { 29 {
30 static void StringToVector(std::vector<uint8_t>& target,
31 const std::string& source)
32 {
33 target.resize(source.size());
34
35 for (size_t i = 0; i < source.size(); i++)
36 {
37 target[i] = source[i];
38 }
39 }
40
41
42 LookupTableTextureSceneLayer::LookupTableTextureSceneLayer(const Orthanc::ImageAccessor& texture) 30 LookupTableTextureSceneLayer::LookupTableTextureSceneLayer(const Orthanc::ImageAccessor& texture)
43 { 31 {
44 { 32 {
45 std::auto_ptr<Orthanc::ImageAccessor> t( 33 std::auto_ptr<Orthanc::ImageAccessor> t(
46 new Orthanc::Image(Orthanc::PixelFormat_Float32, 34 new Orthanc::Image(Orthanc::PixelFormat_Float32,
50 38
51 Orthanc::ImageProcessing::Convert(*t, texture); 39 Orthanc::ImageProcessing::Convert(*t, texture);
52 SetTexture(t.release()); 40 SetTexture(t.release());
53 } 41 }
54 42
55 SetLookupTableGrayscale(); 43 SetLookupTableGrayscale(); // simple ramp between 0 and 255
56 SetRange(0, 1); 44 SetRange(0, 1);
57 } 45 }
58 46
59 47
60 void LookupTableTextureSceneLayer::SetLookupTableGrayscale() 48 void LookupTableTextureSceneLayer::SetLookupTableGrayscale()
127 { 115 {
128 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); 116 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
129 } 117 }
130 } 118 }
131 119
132
133 void LookupTableTextureSceneLayer::SetLookupTable(const std::string& lut)
134 {
135 std::vector<uint8_t> tmp;
136 StringToVector(tmp, lut);
137 SetLookupTable(tmp);
138 }
139
140
141 void LookupTableTextureSceneLayer::SetRange(float minValue, 120 void LookupTableTextureSceneLayer::SetRange(float minValue,
142 float maxValue) 121 float maxValue)
143 { 122 {
144 if (minValue > maxValue) 123 if (minValue > maxValue)
145 { 124 {
156 135
157 void LookupTableTextureSceneLayer::FitRange() 136 void LookupTableTextureSceneLayer::FitRange()
158 { 137 {
159 Orthanc::ImageProcessing::GetMinMaxFloatValue(minValue_, maxValue_, GetTexture()); 138 Orthanc::ImageProcessing::GetMinMaxFloatValue(minValue_, maxValue_, GetTexture());
160 assert(minValue_ <= maxValue_); 139 assert(minValue_ <= maxValue_);
161 140 // TODO: debug to be removed
141 if (fabs(maxValue_ - minValue_) < 0.0001) {
142 LOG(INFO) << "LookupTableTextureSceneLayer::FitRange(): minValue_ = " << minValue_ << " maxValue_ = " << maxValue_;
143 }
162 IncrementRevision(); 144 IncrementRevision();
163 } 145 }
164 146
165 147
166 ISceneLayer* LookupTableTextureSceneLayer::Clone() const 148 ISceneLayer* LookupTableTextureSceneLayer::Clone() const
167 { 149 {
168 std::auto_ptr<LookupTableTextureSceneLayer> cloned 150 std::auto_ptr<LookupTableTextureSceneLayer> cloned
169 (new LookupTableTextureSceneLayer(GetTexture())); 151 (new LookupTableTextureSceneLayer(GetTexture()));
170 152
153
154 // TODO: why is windowing_ not copied??????
171 cloned->CopyParameters(*this); 155 cloned->CopyParameters(*this);
172 cloned->minValue_ = minValue_; 156 cloned->minValue_ = minValue_;
173 cloned->maxValue_ = maxValue_; 157 cloned->maxValue_ = maxValue_;
174 cloned->lut_ = lut_; 158 cloned->lut_ = lut_;
175 159