changeset 323:429c4efa1fde

added option --force-openslide
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 16 Oct 2024 19:36:01 +0200
parents 778e08291d52
children a92bb720f90b
files Applications/Dicomizer.cpp Framework/DicomizerParameters.cpp Framework/DicomizerParameters.h Framework/ImageToolbox.cpp Framework/Inputs/PlainTiff.cpp NEWS
diffstat 6 files changed, 36 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/Dicomizer.cpp	Wed Oct 16 18:42:10 2024 +0200
+++ b/Applications/Dicomizer.cpp	Wed Oct 16 19:36:01 2024 +0200
@@ -60,6 +60,7 @@
 static const char* OPTION_DATASET = "dataset";
 static const char* OPTION_FOLDER = "folder";
 static const char* OPTION_FOLDER_PATTERN = "folder-pattern";
+static const char* OPTION_FORCE_OPENSLIDE = "force-openslide";
 static const char* OPTION_HELP = "help";
 static const char* OPTION_ICC_PROFILE = "icc-profile";
 static const char* OPTION_IMAGED_DEPTH = "imaged-depth";
@@ -580,6 +581,8 @@
     (OPTION_THREADS,
      boost::program_options::value<int>()->default_value(parameters.GetThreadsCount()), 
      "Number of processing threads to be used")
+    (OPTION_FORCE_OPENSLIDE, boost::program_options::value<bool>(),
+     "Whether to force the use of OpenSlide on input TIFF-like files (Boolean)")
     (OPTION_OPENSLIDE, boost::program_options::value<std::string>(), 
      "Path to the shared library of OpenSlide "
      "(not necessary if converting from standard hierarchical TIFF)")
@@ -834,6 +837,12 @@
     OrthancWSI::OpenSlideLibrary::Initialize(options[OPTION_OPENSLIDE].as<std::string>());
   }
 
+  if (options.count(OPTION_FORCE_OPENSLIDE) &&
+      options[OPTION_FORCE_OPENSLIDE].as<bool>())
+  {
+    parameters.SetForceOpenSlide(true);
+  }
+
   if (options.count(OPTION_PYRAMID) &&
       options[OPTION_PYRAMID].as<bool>())
   {
@@ -1075,6 +1084,12 @@
 
     case OrthancWSI::ImageCompression_Tiff:
     {
+      if (parameters.IsForceOpenSlide())
+      {
+        LOG(WARNING) << "Forcing the use of OpenSlide on a TIFF-like file";
+        break;
+      }
+
       try
       {
         std::unique_ptr<OrthancWSI::HierarchicalTiff> tiff(new OrthancWSI::HierarchicalTiff(path));
--- a/Framework/DicomizerParameters.cpp	Wed Oct 16 18:42:10 2024 +0200
+++ b/Framework/DicomizerParameters.cpp	Wed Oct 16 19:36:01 2024 +0200
@@ -75,6 +75,7 @@
     isCytomineSource_(false),
     cytomineImageInstanceId_(-1),
     cytomineCompression_(ImageCompression_Png),
+    forceOpenSlide_(false),
     tiffAlignment_(1)
   {
     backgroundColor_[0] = 255;
--- a/Framework/DicomizerParameters.h	Wed Oct 16 18:42:10 2024 +0200
+++ b/Framework/DicomizerParameters.h	Wed Oct 16 19:36:01 2024 +0200
@@ -69,6 +69,7 @@
     ImageCompression               cytomineCompression_;
 
     // New in release 2.1
+    bool          forceOpenSlide_;
     unsigned int  tiffAlignment_;
 
   public:
@@ -289,5 +290,15 @@
     {
       return tiffAlignment_;
     }
+
+    void SetForceOpenSlide(bool force)
+    {
+      forceOpenSlide_ = force;
+    }
+
+    bool IsForceOpenSlide() const
+    {
+      return forceOpenSlide_;
+    }
   };
 }
--- a/Framework/ImageToolbox.cpp	Wed Oct 16 18:42:10 2024 +0200
+++ b/Framework/ImageToolbox.cpp	Wed Oct 16 19:36:01 2024 +0200
@@ -287,7 +287,6 @@
       const unsigned int width = image.GetWidth();
       const unsigned int height = image.GetHeight();
       const unsigned int pitch = image.GetPitch();
-      uint8_t* buffer = reinterpret_cast<uint8_t*>(image.GetBuffer());
         
       if (image.GetFormat() != Orthanc::PixelFormat_RGB24 ||
           pitch < 3 * width)
@@ -297,7 +296,7 @@
 
       for (unsigned int y = 0; y < height; y++)
       {
-        uint8_t* p = buffer + y * pitch;
+        uint8_t* p = reinterpret_cast<uint8_t*>(image.GetRow(y));
           
         for (unsigned int x = 0; x < width; x++, p += 3)
         {
--- a/Framework/Inputs/PlainTiff.cpp	Wed Oct 16 18:42:10 2024 +0200
+++ b/Framework/Inputs/PlainTiff.cpp	Wed Oct 16 19:36:01 2024 +0200
@@ -23,6 +23,7 @@
 
 #include "PlainTiff.h"
 
+#include "../ImageToolbox.h"
 #include "../TiffReader.h"
 
 #include <Images/Image.h>
@@ -162,6 +163,11 @@
       }
     }
 
+    if (photometric == Orthanc::PhotometricInterpretation_YBRFull422)
+    {
+      ImageToolbox::ConvertJpegYCbCrToRgb(*decoded_);
+    }
+
     SetImage(*decoded_);
   }
 }
--- a/NEWS	Wed Oct 16 18:42:10 2024 +0200
+++ b/NEWS	Wed Oct 16 19:36:01 2024 +0200
@@ -3,7 +3,8 @@
 
 * Support of sparse encoding of tiles in OpenSlide (notably for MIRAX format)
 * OrthancWSIDicomizer supports plain TIFF, besides hierarchical TIFF
-* New option: "tiff-alignment" to control deep zoom of plain TIFF over IIIF
+* New option: "--force-openslide" to force the use of OpenSlide on TIFF-like files
+* New option: "--tiff-alignment" to control deep zoom of plain TIFF over IIIF
 * Force version of Mirador to 3.3.0
 * In the IIIF manifest, reverse the order of the "sizes" field, which
   seems to fix compatibility with Mirador v4.0.0-alpha