Mercurial > hg > orthanc-wsi
changeset 219:ef3f8c5126a4
Don't display the thumbnail/overview instances in the Web viewer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 12 Jan 2021 17:09:57 +0100 |
parents | c5a8b46c4cba |
children | 7ffcce8ec94c |
files | Framework/Inputs/DicomPyramid.cpp Framework/Inputs/DicomPyramidInstance.cpp Framework/Inputs/DicomPyramidInstance.h NEWS |
diffstat | 4 files changed, 40 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/Framework/Inputs/DicomPyramid.cpp Tue Jan 12 16:20:57 2021 +0100 +++ b/Framework/Inputs/DicomPyramid.cpp Tue Jan 12 17:09:57 2021 +0100 @@ -23,8 +23,11 @@ #include "DicomPyramid.h" #include "../DicomToolbox.h" + +#include <Compatibility.h> #include <Logging.h> #include <OrthancException.h> +#include <Toolbox.h> #include <algorithm> #include <cassert> @@ -84,15 +87,26 @@ throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); } - std::string instance = instances[i].asString(); + std::string instanceId = instances[i].asString(); try { - instances_.push_back(new DicomPyramidInstance(orthanc_, instance, useCache)); + std::unique_ptr<DicomPyramidInstance> instance(new DicomPyramidInstance(orthanc_, instanceId, useCache)); + + std::vector<std::string> tokens; + Orthanc::Toolbox::TokenizeString(tokens, instance->GetImageType(), '\\'); + + // Don't consider the thumbnail and overview as part of the DICOM pyramid (new in 0.8) + if (tokens.size() < 2 || + (tokens[2] != "THUMBNAIL" && + tokens[2] != "OVERVIEW")) + { + instances_.push_back(instance.release()); + } } catch (Orthanc::OrthancException&) { - LOG(ERROR) << "Skipping a DICOM instance that is not part of a whole-slide image: " << instance; + LOG(ERROR) << "Skipping a DICOM instance that is not part of a whole-slide image: " << instanceId; } } }
--- a/Framework/Inputs/DicomPyramidInstance.cpp Tue Jan 12 16:20:57 2021 +0100 +++ b/Framework/Inputs/DicomPyramidInstance.cpp Tue Jan 12 17:09:57 2021 +0100 @@ -44,6 +44,7 @@ static const Orthanc::DicomTag DICOM_TAG_ROW_POSITION_IN_TOTAL_IMAGE_PIXEL_MATRIX(0x0048, 0x021f); static const Orthanc::DicomTag DICOM_TAG_TOTAL_PIXEL_MATRIX_COLUMNS(0x0048, 0x0006); static const Orthanc::DicomTag DICOM_TAG_TOTAL_PIXEL_MATRIX_ROWS(0x0048, 0x0007); + static const Orthanc::DicomTag DICOM_TAG_IMAGE_TYPE(0x0008, 0x0008); static ImageCompression DetectImageCompression(OrthancStone::IOrthancConnection& orthanc, const std::string& instanceId) @@ -173,6 +174,8 @@ throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); } + imageType_ = reader.GetStringValue(OrthancStone::DicomPath(DICOM_TAG_IMAGE_TYPE), ""); + size_t countFrames; if (reader.GetDataset().GetSequenceSize(countFrames, OrthancStone::DicomPath(DICOM_TAG_PER_FRAME_FUNCTIONAL_GROUPS_SEQUENCE))) { @@ -271,7 +274,6 @@ // Try and deserialized the cached information about this instance std::string serialized; orthanc.RestApiGet(serialized, "/instances/" + instanceId + "/metadata/" + SERIALIZED_METADATA); - std::cout << serialized; Deserialize(serialized); return; // Success } @@ -318,6 +320,7 @@ static const char* const TOTAL_WIDTH = "TotalWidth"; static const char* const TOTAL_HEIGHT = "TotalHeight"; static const char* const PHOTOMETRIC_INTERPRETATION = "PhotometricInterpretation"; + static const char* const IMAGE_TYPE = "ImageType"; void DicomPyramidInstance::Serialize(std::string& result) const @@ -344,6 +347,7 @@ content[TOTAL_WIDTH] = totalWidth_; content[TOTAL_HEIGHT] = totalHeight_; content[PHOTOMETRIC_INTERPRETATION] = Orthanc::EnumerationToString(photometric_); + content[IMAGE_TYPE] = imageType_; Orthanc::Toolbox::WriteFastJson(result, content); } @@ -371,6 +375,8 @@ std::string p = Orthanc::SerializationToolbox::ReadString(content, PHOTOMETRIC_INTERPRETATION); photometric_ = Orthanc::StringToPhotometricInterpretation(p.c_str()); + + imageType_ = Orthanc::SerializationToolbox::ReadString(content, IMAGE_TYPE); const Json::Value f = content[FRAMES]; frames_.resize(f.size());
--- a/Framework/Inputs/DicomPyramidInstance.h Tue Jan 12 16:20:57 2021 +0100 +++ b/Framework/Inputs/DicomPyramidInstance.h Tue Jan 12 17:09:57 2021 +0100 @@ -34,16 +34,17 @@ private: typedef std::pair<unsigned int, unsigned int> FrameLocation; - std::string instanceId_; - bool hasCompression_; - ImageCompression compression_; - Orthanc::PixelFormat format_; - unsigned int tileWidth_; - unsigned int tileHeight_; - unsigned int totalWidth_; - unsigned int totalHeight_; - std::vector<FrameLocation> frames_; + std::string instanceId_; + bool hasCompression_; + ImageCompression compression_; + Orthanc::PixelFormat format_; + unsigned int tileWidth_; + unsigned int tileHeight_; + unsigned int totalWidth_; + unsigned int totalHeight_; + std::vector<FrameLocation> frames_; Orthanc::PhotometricInterpretation photometric_; + std::string imageType_; void Load(OrthancStone::IOrthancConnection& orthanc, const std::string& instanceId); @@ -97,6 +98,11 @@ return frames_.size(); } + const std::string& GetImageType() const + { + return imageType_; + } + unsigned int GetFrameLocationX(size_t frame) const; unsigned int GetFrameLocationY(size_t frame) const;
--- a/NEWS Tue Jan 12 16:20:57 2021 +0100 +++ b/NEWS Tue Jan 12 17:09:57 2021 +0100 @@ -5,6 +5,7 @@ * Allow images without "Per frame functional groups sequence" tag (0x5200,0x9230) * Better handling of PhotometricInterpretation in viewer * Fix colorspace of TIFF containing JPEG with RGB photometric interpretation (not YCbCr) +* Don't display the thumbnail/overview instances in the Web viewer * Support of dynamic linking against the system-wide Orthanc framework library