Mercurial > hg > orthanc-wsi
comparison Framework/Inputs/DicomPyramidInstance.cpp @ 56:83cd735c885d
speedup the loading of DICOM sources
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 24 Nov 2016 15:41:21 +0100 |
parents | 7a88c614be04 |
children | 7a3853d51c45 |
comparison
equal
deleted
inserted
replaced
55:b6432a00b103 | 56:83cd735c885d |
---|---|
89 LOG(ERROR) << "Unsupported pixel format"; | 89 LOG(ERROR) << "Unsupported pixel format"; |
90 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | 90 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
91 } | 91 } |
92 } | 92 } |
93 | 93 |
94 | |
95 ImageCompression DicomPyramidInstance::GetImageCompression(IOrthancConnection& orthanc) | |
96 { | |
97 /** | |
98 * Lazy detection of the image compression using the transfer | |
99 * syntax stored inside the DICOM header. Given the fact that | |
100 * reading the header is a time-consuming operation (it implies | |
101 * the decoding of the DICOM image by Orthanc, whereas the "/tags" | |
102 * endpoint only reads the "DICOM-as-JSON" attachment), the | |
103 * "/header" REST call is delayed until it is really required. | |
104 **/ | |
105 | |
106 if (!hasCompression_) | |
107 { | |
108 Json::Value header; | |
109 IOrthancConnection::RestApiGet(header, orthanc, "/instances/" + instanceId_ + "/header?simplify"); | |
110 | |
111 hasCompression_ = true; | |
112 compression_ = DetectImageCompression(header); | |
113 } | |
114 | |
115 return compression_; | |
116 } | |
117 | |
94 | 118 |
95 DicomPyramidInstance::DicomPyramidInstance(IOrthancConnection& orthanc, | 119 DicomPyramidInstance::DicomPyramidInstance(IOrthancConnection& orthanc, |
96 const std::string& instanceId) : | 120 const std::string& instanceId) : |
97 instanceId_(instanceId) | 121 instanceId_(instanceId), |
122 hasCompression_(false) | |
98 { | 123 { |
99 Json::Value dicom, header; | 124 Json::Value dicom; |
100 IOrthancConnection::RestApiGet(dicom, orthanc, "/instances/" + instanceId + "/tags?simplify"); | 125 IOrthancConnection::RestApiGet(dicom, orthanc, "/instances/" + instanceId + "/tags?simplify"); |
101 IOrthancConnection::RestApiGet(header, orthanc, "/instances/" + instanceId + "/header?simplify"); | |
102 | 126 |
103 if (DicomToolbox::GetMandatoryStringTag(dicom, "SOPClassUID") != "1.2.840.10008.5.1.4.1.1.77.1.6" || | 127 if (DicomToolbox::GetMandatoryStringTag(dicom, "SOPClassUID") != "1.2.840.10008.5.1.4.1.1.77.1.6" || |
104 DicomToolbox::GetMandatoryStringTag(dicom, "Modality") != "SM") | 128 DicomToolbox::GetMandatoryStringTag(dicom, "Modality") != "SM") |
105 { | 129 { |
106 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | 130 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
107 } | 131 } |
108 | 132 |
109 compression_ = DetectImageCompression(header); | |
110 format_ = DetectPixelFormat(dicom); | 133 format_ = DetectPixelFormat(dicom); |
111 tileWidth_ = DicomToolbox::GetUnsignedIntegerTag(dicom, "Columns"); | 134 tileWidth_ = DicomToolbox::GetUnsignedIntegerTag(dicom, "Columns"); |
112 tileHeight_ = DicomToolbox::GetUnsignedIntegerTag(dicom, "Rows"); | 135 tileHeight_ = DicomToolbox::GetUnsignedIntegerTag(dicom, "Rows"); |
113 totalWidth_ = DicomToolbox::GetUnsignedIntegerTag(dicom, "TotalPixelMatrixColumns"); | 136 totalWidth_ = DicomToolbox::GetUnsignedIntegerTag(dicom, "TotalPixelMatrixColumns"); |
114 totalHeight_ = DicomToolbox::GetUnsignedIntegerTag(dicom, "TotalPixelMatrixRows"); | 137 totalHeight_ = DicomToolbox::GetUnsignedIntegerTag(dicom, "TotalPixelMatrixRows"); |