changeset 2031:a56f7ed0cdf9 deep-learning

integration mainline->deep-learning
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 23 Dec 2022 17:51:07 +0100
parents 0cb8796c2a9b (current diff) f36de3ba43c8 (diff)
children d10bab7cc396
files Applications/StoneWebViewer/WebApplication/app.js Applications/StoneWebViewer/WebApplication/index.html Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp
diffstat 4 files changed, 54 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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)
 ========================
--- 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 != '') {
--- 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 }} <small>({{ preset.info }})</small>
                     </a>
                   </li>
+                  <li class="wvToolbar__windowingPresetListItem">
+                    <a href="#" v-on:click="StretchWindowing()">
+                      Stretch to whole range
+                    </a>
+                  </li>
                   <li v-for="preset in globalConfiguration.WindowingPresets"
                       class="wvToolbar__windowingPresetListItem">
                     <a href="#" v-on:click="SetWindowing(preset.WindowCenter, preset.WindowWidth)">
--- 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<OrthancStone::IViewport::ILock> 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<OrthancStone::FloatTextureSceneLayer&>(
+          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