Mercurial > hg > orthanc-wsi
comparison Framework/Inputs/DicomPyramidInstance.cpp @ 89:61e629ce7c94
sync
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 16 Dec 2016 21:13:29 +0100 |
parents | 3d83d34cd4db |
children | ff0ef01c332c |
comparison
equal
deleted
inserted
replaced
88:7dffa59c498d | 89:61e629ce7c94 |
---|---|
79 { | 79 { |
80 LOG(ERROR) << "Unsupported photometric interpretation: " << photometric; | 80 LOG(ERROR) << "Unsupported photometric interpretation: " << photometric; |
81 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | 81 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
82 } | 82 } |
83 | 83 |
84 unsigned int bitsStored = reader.GetUnsignedIntegerValue(DICOM_TAG_BITS_STORED); | 84 unsigned int bitsStored, samplesPerPixel, tmp; |
85 unsigned int samplesPerPixel = reader.GetUnsignedIntegerValue(DICOM_TAG_SAMPLES_PER_PIXEL); | 85 |
86 bool isSigned = (reader.GetUnsignedIntegerValue(DICOM_TAG_PIXEL_REPRESENTATION) != 0); | 86 if (!reader.GetUnsignedIntegerValue(bitsStored, DICOM_TAG_BITS_STORED) || |
87 !reader.GetUnsignedIntegerValue(samplesPerPixel, DICOM_TAG_SAMPLES_PER_PIXEL) || | |
88 !reader.GetUnsignedIntegerValue(tmp, DICOM_TAG_PIXEL_REPRESENTATION)) | |
89 { | |
90 throw Orthanc::OrthancException(Orthanc::ErrorCode_InexistentTag); | |
91 } | |
92 | |
93 bool isSigned = (tmp != 0); | |
87 | 94 |
88 if (bitsStored == 8 && | 95 if (bitsStored == 8 && |
89 samplesPerPixel == 1 && | 96 samplesPerPixel == 1 && |
90 !isSigned) | 97 !isSigned) |
91 { | 98 { |
140 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | 147 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
141 } | 148 } |
142 | 149 |
143 hasCompression_ = false; | 150 hasCompression_ = false; |
144 format_ = DetectPixelFormat(reader); | 151 format_ = DetectPixelFormat(reader); |
145 tileWidth_ = reader.GetUnsignedIntegerValue(DICOM_TAG_COLUMNS); | 152 |
146 tileHeight_ = reader.GetUnsignedIntegerValue(DICOM_TAG_ROWS); | 153 unsigned int tmp; |
147 totalWidth_ = reader.GetUnsignedIntegerValue(DICOM_TAG_TOTAL_PIXEL_MATRIX_COLUMNS); | 154 if (!reader.GetUnsignedIntegerValue(tileWidth_, DICOM_TAG_COLUMNS) || |
148 totalHeight_ = reader.GetUnsignedIntegerValue(DICOM_TAG_TOTAL_PIXEL_MATRIX_ROWS); | 155 !reader.GetUnsignedIntegerValue(tileHeight_, DICOM_TAG_ROWS) || |
156 !reader.GetUnsignedIntegerValue(totalWidth_, DICOM_TAG_TOTAL_PIXEL_MATRIX_COLUMNS) || | |
157 !reader.GetUnsignedIntegerValue(totalHeight_, DICOM_TAG_TOTAL_PIXEL_MATRIX_ROWS) || | |
158 !reader.GetUnsignedIntegerValue(tmp, DICOM_TAG_NUMBER_OF_FRAMES)) | |
159 { | |
160 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); | |
161 } | |
149 | 162 |
150 size_t countFrames; | 163 size_t countFrames; |
151 if (!reader.GetDataset().GetSequenceSize(countFrames, DICOM_TAG_PER_FRAME_FUNCTIONAL_GROUPS_SEQUENCE)) | 164 if (!reader.GetDataset().GetSequenceSize(countFrames, DICOM_TAG_PER_FRAME_FUNCTIONAL_GROUPS_SEQUENCE)) |
152 { | 165 { |
153 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); | 166 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
154 } | 167 } |
155 | 168 |
156 if (countFrames != reader.GetUnsignedIntegerValue(DICOM_TAG_NUMBER_OF_FRAMES)) | 169 if (countFrames != tmp) |
157 { | 170 { |
158 LOG(ERROR) << "Mismatch between the number of frames in instance: " << instanceId; | 171 LOG(ERROR) << "Mismatch between the number of frames in instance: " << instanceId; |
159 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); | 172 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); |
160 } | 173 } |
161 | 174 |
162 frames_.resize(countFrames); | 175 frames_.resize(countFrames); |
163 | 176 |
164 for (size_t i = 0; i < countFrames; i++) | 177 for (size_t i = 0; i < countFrames; i++) |
165 { | 178 { |
166 int xx = reader.GetIntegerValue(DicomPath(DICOM_TAG_PER_FRAME_FUNCTIONAL_GROUPS_SEQUENCE, i, | 179 DicomPath pathX(DICOM_TAG_PER_FRAME_FUNCTIONAL_GROUPS_SEQUENCE, i, |
167 DICOM_TAG_PLANE_POSITION_SLIDE_SEQUENCE, 0, | 180 DICOM_TAG_PLANE_POSITION_SLIDE_SEQUENCE, 0, |
168 DICOM_TAG_COLUMN_POSITION_IN_TOTAL_IMAGE_PIXEL_MATRIX)); | 181 DICOM_TAG_COLUMN_POSITION_IN_TOTAL_IMAGE_PIXEL_MATRIX); |
169 | 182 |
170 int yy = reader.GetIntegerValue(DicomPath(DICOM_TAG_PER_FRAME_FUNCTIONAL_GROUPS_SEQUENCE, i, | 183 DicomPath pathY(DICOM_TAG_PER_FRAME_FUNCTIONAL_GROUPS_SEQUENCE, i, |
171 DICOM_TAG_PLANE_POSITION_SLIDE_SEQUENCE, 0, | 184 DICOM_TAG_PLANE_POSITION_SLIDE_SEQUENCE, 0, |
172 DICOM_TAG_ROW_POSITION_IN_TOTAL_IMAGE_PIXEL_MATRIX)); | 185 DICOM_TAG_ROW_POSITION_IN_TOTAL_IMAGE_PIXEL_MATRIX); |
186 | |
187 int xx, yy; | |
188 if (!reader.GetIntegerValue(xx, pathX) || | |
189 !reader.GetIntegerValue(yy, pathY)) | |
190 { | |
191 throw Orthanc::OrthancException(Orthanc::ErrorCode_InexistentTag); | |
192 } | |
173 | 193 |
174 // "-1", because coordinates are shifted by 1 in DICOM | 194 // "-1", because coordinates are shifted by 1 in DICOM |
175 xx -= 1; | 195 xx -= 1; |
176 yy -= 1; | 196 yy -= 1; |
177 | 197 |