# HG changeset patch # User Sebastien Jodogne # Date 1729100161 -7200 # Node ID 429c4efa1fde2e035500429e72485d0ad29eab8c # Parent 778e08291d52d8ac954a81e1057075702838758c added option --force-openslide diff -r 778e08291d52 -r 429c4efa1fde Applications/Dicomizer.cpp --- 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()->default_value(parameters.GetThreadsCount()), "Number of processing threads to be used") + (OPTION_FORCE_OPENSLIDE, boost::program_options::value(), + "Whether to force the use of OpenSlide on input TIFF-like files (Boolean)") (OPTION_OPENSLIDE, boost::program_options::value(), "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()); } + if (options.count(OPTION_FORCE_OPENSLIDE) && + options[OPTION_FORCE_OPENSLIDE].as()) + { + parameters.SetForceOpenSlide(true); + } + if (options.count(OPTION_PYRAMID) && options[OPTION_PYRAMID].as()) { @@ -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 tiff(new OrthancWSI::HierarchicalTiff(path)); diff -r 778e08291d52 -r 429c4efa1fde Framework/DicomizerParameters.cpp --- 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; diff -r 778e08291d52 -r 429c4efa1fde Framework/DicomizerParameters.h --- 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_; + } }; } diff -r 778e08291d52 -r 429c4efa1fde Framework/ImageToolbox.cpp --- 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(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(image.GetRow(y)); for (unsigned int x = 0; x < width; x++, p += 3) { diff -r 778e08291d52 -r 429c4efa1fde Framework/Inputs/PlainTiff.cpp --- 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 @@ -162,6 +163,11 @@ } } + if (photometric == Orthanc::PhotometricInterpretation_YBRFull422) + { + ImageToolbox::ConvertJpegYCbCrToRgb(*decoded_); + } + SetImage(*decoded_); } } diff -r 778e08291d52 -r 429c4efa1fde NEWS --- 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