Mercurial > hg > orthanc-stone
diff OrthancStone/Sources/Loaders/SeriesFramesLoader.cpp @ 1679:5b8b88e5bfd6
successfully running unit tests in WebAssembly
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 24 Nov 2020 12:59:10 +0100 |
parents | 51bab5188a13 |
children | 0257339b0884 |
line wrap: on
line diff
--- a/OrthancStone/Sources/Loaders/SeriesFramesLoader.cpp Tue Nov 24 07:40:19 2020 +0100 +++ b/OrthancStone/Sources/Loaders/SeriesFramesLoader.cpp Tue Nov 24 12:59:10 2020 +0100 @@ -307,77 +307,6 @@ } - static void GetBounds(float& low, - float& high, - double center, // in - double width) // in - { - low = static_cast<float>(center - width / 2.0); - high = static_cast<float>(center + width / 2.0); - } - - - void SeriesFramesLoader::GetPreviewWindowing(float& center, - float& width, - size_t index) const - { - const Orthanc::DicomMap& instance = frames_.GetInstance(index); - const DicomInstanceParameters& parameters = frames_.GetInstanceParameters(index); - - size_t s = parameters.GetPresetWindowingsCount(); - - if (s > 0) - { - // Use the largest windowing given all the preset windowings - // that are available in the DICOM tags - float low, high; - GetBounds(low, high, parameters.GetPresetWindowingCenter(0), - parameters.GetPresetWindowingWidth(0)); - - for (size_t i = 1; i < s; i++) - { - float a, b; - GetBounds(a, b, parameters.GetPresetWindowingCenter(i), - parameters.GetPresetWindowingWidth(i)); - low = std::min(low, a); - high = std::max(high, b); - } - - assert(low <= high); - - if (LinearAlgebra::IsNear(low, high)) - { - // Cannot infer a suitable windowing from the available tags - center = 128.0f; - width = 256.0f; - } - else - { - center = (low + high) / 2.0f; - width = (high - low); - printf(">> %f %f\n", center, width); - } - } - else - { - float a, b; - if (instance.ParseFloat(a, Orthanc::DICOM_TAG_SMALLEST_IMAGE_PIXEL_VALUE) && - instance.ParseFloat(b, Orthanc::DICOM_TAG_LARGEST_IMAGE_PIXEL_VALUE) && - a < b) - { - center = (a + b) / 2.0f; - width = (b - a); - } - else - { - // Cannot infer a suitable windowing from the available tags - center = 128.0f; - width = 256.0f; - } - } - } - - Orthanc::IDynamicObject& SeriesFramesLoader::FrameLoadedMessage::GetUserPayload() const { if (userPayload_) @@ -485,8 +414,10 @@ if (source.HasDicomWebRendered() && quality == 0) { + const DicomInstanceParameters& parameters = frames_.GetInstanceParameters(index); + float c, w; - GetPreviewWindowing(c, w, index); + parameters.GetWindowingPresetsUnion(c, w); std::map<std::string, std::string> arguments, headers; arguments["window"] = (boost::lexical_cast<std::string>(c) + "," +