comparison Core/DicomParsing/ParsedDicomFile.cpp @ 2910:83133583183d

minor fixes if embedding images within DICOM
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 30 Oct 2018 18:28:44 +0100
parents 9d277f8ad698
children 22524fd06225
comparison
equal deleted inserted replaced
2908:9d277f8ad698 2910:83133583183d
1181 1181
1182 Remove(DICOM_TAG_PIXEL_DATA); 1182 Remove(DICOM_TAG_PIXEL_DATA);
1183 ReplacePlainString(DICOM_TAG_COLUMNS, boost::lexical_cast<std::string>(accessor.GetWidth())); 1183 ReplacePlainString(DICOM_TAG_COLUMNS, boost::lexical_cast<std::string>(accessor.GetWidth()));
1184 ReplacePlainString(DICOM_TAG_ROWS, boost::lexical_cast<std::string>(accessor.GetHeight())); 1184 ReplacePlainString(DICOM_TAG_ROWS, boost::lexical_cast<std::string>(accessor.GetHeight()));
1185 ReplacePlainString(DICOM_TAG_SAMPLES_PER_PIXEL, "1"); 1185 ReplacePlainString(DICOM_TAG_SAMPLES_PER_PIXEL, "1");
1186 ReplacePlainString(DICOM_TAG_NUMBER_OF_FRAMES, "1"); 1186
1187 // The "Number of frames" must only be present in multi-frame images
1188 //ReplacePlainString(DICOM_TAG_NUMBER_OF_FRAMES, "1");
1187 1189
1188 if (accessor.GetFormat() == PixelFormat_SignedGrayscale16) 1190 if (accessor.GetFormat() == PixelFormat_SignedGrayscale16)
1189 { 1191 {
1190 ReplacePlainString(DICOM_TAG_PIXEL_REPRESENTATION, "1"); 1192 ReplacePlainString(DICOM_TAG_PIXEL_REPRESENTATION, "1");
1191 } 1193 }
1192 else 1194 else
1193 { 1195 {
1194 ReplacePlainString(DICOM_TAG_PIXEL_REPRESENTATION, "0"); // Unsigned pixels 1196 ReplacePlainString(DICOM_TAG_PIXEL_REPRESENTATION, "0"); // Unsigned pixels
1195 } 1197 }
1196 1198
1197 ReplacePlainString(DICOM_TAG_PLANAR_CONFIGURATION, "0"); // Color channels are interleaved
1198 SetIfAbsent(DICOM_TAG_PHOTOMETRIC_INTERPRETATION, "MONOCHROME2"); // by default, greyscale images are in MONOCHROME2
1199
1200 unsigned int bytesPerPixel = 0; 1199 unsigned int bytesPerPixel = 0;
1201 1200
1202 switch (accessor.GetFormat()) 1201 switch (accessor.GetFormat())
1203 { 1202 {
1204 case PixelFormat_Grayscale8: 1203 case PixelFormat_Grayscale8:
1204 // By default, grayscale images are MONOCHROME2
1205 SetIfAbsent(DICOM_TAG_PHOTOMETRIC_INTERPRETATION, "MONOCHROME2");
1206
1205 ReplacePlainString(DICOM_TAG_BITS_ALLOCATED, "8"); 1207 ReplacePlainString(DICOM_TAG_BITS_ALLOCATED, "8");
1206 ReplacePlainString(DICOM_TAG_BITS_STORED, "8"); 1208 ReplacePlainString(DICOM_TAG_BITS_STORED, "8");
1207 ReplacePlainString(DICOM_TAG_HIGH_BIT, "7"); 1209 ReplacePlainString(DICOM_TAG_HIGH_BIT, "7");
1208 bytesPerPixel = 1; 1210 bytesPerPixel = 1;
1209 break; 1211 break;
1214 ReplacePlainString(DICOM_TAG_SAMPLES_PER_PIXEL, "3"); 1216 ReplacePlainString(DICOM_TAG_SAMPLES_PER_PIXEL, "3");
1215 ReplacePlainString(DICOM_TAG_BITS_ALLOCATED, "8"); 1217 ReplacePlainString(DICOM_TAG_BITS_ALLOCATED, "8");
1216 ReplacePlainString(DICOM_TAG_BITS_STORED, "8"); 1218 ReplacePlainString(DICOM_TAG_BITS_STORED, "8");
1217 ReplacePlainString(DICOM_TAG_HIGH_BIT, "7"); 1219 ReplacePlainString(DICOM_TAG_HIGH_BIT, "7");
1218 bytesPerPixel = 3; 1220 bytesPerPixel = 3;
1221
1222 // "Planar configuration" must only present if "Samples per
1223 // Pixel" is greater than 1
1224 ReplacePlainString(DICOM_TAG_PLANAR_CONFIGURATION, "0"); // Color channels are interleaved
1225
1219 break; 1226 break;
1220 1227
1221 case PixelFormat_Grayscale16: 1228 case PixelFormat_Grayscale16:
1222 case PixelFormat_SignedGrayscale16: 1229 case PixelFormat_SignedGrayscale16:
1230 // By default, grayscale images are MONOCHROME2
1231 SetIfAbsent(DICOM_TAG_PHOTOMETRIC_INTERPRETATION, "MONOCHROME2");
1232
1223 ReplacePlainString(DICOM_TAG_BITS_ALLOCATED, "16"); 1233 ReplacePlainString(DICOM_TAG_BITS_ALLOCATED, "16");
1224 ReplacePlainString(DICOM_TAG_BITS_STORED, "16"); 1234 ReplacePlainString(DICOM_TAG_BITS_STORED, "16");
1225 ReplacePlainString(DICOM_TAG_HIGH_BIT, "15"); 1235 ReplacePlainString(DICOM_TAG_HIGH_BIT, "15");
1226 bytesPerPixel = 2; 1236 bytesPerPixel = 2;
1227 break; 1237 break;