# HG changeset patch # User Sebastien Jodogne # Date 1671814267 -3600 # Node ID a56f7ed0cdf948261e3a8703b9940d867d814729 # Parent 0cb8796c2a9b4a81b0073e0958b98999f139aaa6# Parent f36de3ba43c8684262a1e7e7f52818819ca64625 integration mainline->deep-learning diff -r 0cb8796c2a9b -r a56f7ed0cdf9 Applications/StoneWebViewer/NEWS --- a/Applications/StoneWebViewer/NEWS Fri Dec 23 16:58:13 2022 +0100 +++ b/Applications/StoneWebViewer/NEWS Fri Dec 23 17:51:07 2022 +0100 @@ -1,6 +1,8 @@ Pending changes in the mainline =============================== +* New button "Stretch to whole range" in the "Change windowing" menu + Version 2.5 (2022-12-05) ======================== diff -r 0cb8796c2a9b -r a56f7ed0cdf9 Applications/StoneWebViewer/WebApplication/app.js --- a/Applications/StoneWebViewer/WebApplication/app.js Fri Dec 23 16:58:13 2022 +0100 +++ b/Applications/StoneWebViewer/WebApplication/app.js Fri Dec 23 17:51:07 2022 +0100 @@ -1038,6 +1038,14 @@ } }, + StretchWindowing: function(center, width) { + this.showWindowing = false; + var canvas = this.GetActiveCanvas(); + if (canvas != '') { + stone.StretchWindowing(canvas); + } + }, + InvertContrast: function() { var canvas = this.GetActiveCanvas(); if (canvas != '') { diff -r 0cb8796c2a9b -r a56f7ed0cdf9 Applications/StoneWebViewer/WebApplication/index.html --- a/Applications/StoneWebViewer/WebApplication/index.html Fri Dec 23 16:58:13 2022 +0100 +++ b/Applications/StoneWebViewer/WebApplication/index.html Fri Dec 23 17:51:07 2022 +0100 @@ -488,6 +488,11 @@ {{ preset.name }} ({{ preset.info }}) +
  • + + Stretch to whole range + +
  • diff -r 0cb8796c2a9b -r a56f7ed0cdf9 Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp --- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Fri Dec 23 16:58:13 2022 +0100 +++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Fri Dec 23 17:51:07 2022 +0100 @@ -3127,6 +3127,34 @@ } } + void StretchWindowing() + { + float minValue, maxValue; + + { + std::unique_ptr lock(viewport_->Lock()); + + if (!lock->GetController().GetScene().HasLayer(LAYER_TEXTURE) || + lock->GetController().GetScene().GetLayer(LAYER_TEXTURE).GetType() != + OrthancStone::ISceneLayer::Type_FloatTexture) + { + return; + } + + const Orthanc::ImageAccessor& texture = + dynamic_cast( + lock->GetController().GetScene().GetLayer(LAYER_TEXTURE)).GetTexture(); + if (texture.GetFormat() != Orthanc::PixelFormat_Float32) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + } + + Orthanc::ImageProcessing::GetMinMaxFloatValue(minValue, maxValue, texture); + } + + SetWindowing((minValue + maxValue) / 2.0f, maxValue - minValue); + } + void FlipX() { { @@ -4599,6 +4627,17 @@ EMSCRIPTEN_KEEPALIVE + void StretchWindowing(const char* canvas) + { + try + { + GetViewport(canvas)->StretchWindowing(); + } + EXTERN_CATCH_EXCEPTIONS; + } + + + EMSCRIPTEN_KEEPALIVE void InvertContrast(const char* canvas) { try