Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Loaders/SeriesFramesLoader.cpp @ 1677:51bab5188a13
start multiple preset windowings
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 23 Nov 2020 19:24:18 +0100 |
parents | 8563ea5d8ae4 |
children | 5b8b88e5bfd6 |
comparison
equal
deleted
inserted
replaced
1676:5e76d5e8167a | 1677:51bab5188a13 |
---|---|
305 HandleDicomWebRendered(dynamic_cast<const Payload&>(message.GetOrigin().GetPayload()), | 305 HandleDicomWebRendered(dynamic_cast<const Payload&>(message.GetOrigin().GetPayload()), |
306 message.GetAnswer(), message.GetAnswerHeaders()); | 306 message.GetAnswer(), message.GetAnswerHeaders()); |
307 } | 307 } |
308 | 308 |
309 | 309 |
310 static void GetBounds(float& low, | |
311 float& high, | |
312 double center, // in | |
313 double width) // in | |
314 { | |
315 low = static_cast<float>(center - width / 2.0); | |
316 high = static_cast<float>(center + width / 2.0); | |
317 } | |
318 | |
319 | |
310 void SeriesFramesLoader::GetPreviewWindowing(float& center, | 320 void SeriesFramesLoader::GetPreviewWindowing(float& center, |
311 float& width, | 321 float& width, |
312 size_t index) const | 322 size_t index) const |
313 { | 323 { |
314 const Orthanc::DicomMap& instance = frames_.GetInstance(index); | 324 const Orthanc::DicomMap& instance = frames_.GetInstance(index); |
315 const DicomInstanceParameters& parameters = frames_.GetInstanceParameters(index); | 325 const DicomInstanceParameters& parameters = frames_.GetInstanceParameters(index); |
316 | 326 |
317 if (parameters.HasDefaultWindowing()) | 327 size_t s = parameters.GetPresetWindowingsCount(); |
318 { | 328 |
319 // TODO - Handle multiple presets (take the largest width) | 329 if (s > 0) |
320 center = parameters.GetDefaultWindowingCenter(); | 330 { |
321 width = parameters.GetDefaultWindowingWidth(); | 331 // Use the largest windowing given all the preset windowings |
332 // that are available in the DICOM tags | |
333 float low, high; | |
334 GetBounds(low, high, parameters.GetPresetWindowingCenter(0), | |
335 parameters.GetPresetWindowingWidth(0)); | |
336 | |
337 for (size_t i = 1; i < s; i++) | |
338 { | |
339 float a, b; | |
340 GetBounds(a, b, parameters.GetPresetWindowingCenter(i), | |
341 parameters.GetPresetWindowingWidth(i)); | |
342 low = std::min(low, a); | |
343 high = std::max(high, b); | |
344 } | |
345 | |
346 assert(low <= high); | |
347 | |
348 if (LinearAlgebra::IsNear(low, high)) | |
349 { | |
350 // Cannot infer a suitable windowing from the available tags | |
351 center = 128.0f; | |
352 width = 256.0f; | |
353 } | |
354 else | |
355 { | |
356 center = (low + high) / 2.0f; | |
357 width = (high - low); | |
358 printf(">> %f %f\n", center, width); | |
359 } | |
322 } | 360 } |
323 else | 361 else |
324 { | 362 { |
325 float a, b; | 363 float a, b; |
326 if (instance.ParseFloat(a, Orthanc::DICOM_TAG_SMALLEST_IMAGE_PIXEL_VALUE) && | 364 if (instance.ParseFloat(a, Orthanc::DICOM_TAG_SMALLEST_IMAGE_PIXEL_VALUE) && |