changeset 2889:f3c1eda54e47

Allow creation of MONOCHROME1 greyscale images in tools/create-dicom
author amazy
date Mon, 15 Oct 2018 13:45:00 +0200
parents 61a5667f37d9
children f5ce33d3295c
files Core/DicomParsing/ParsedDicomFile.cpp Core/DicomParsing/ParsedDicomFile.h NEWS
diffstat 3 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Core/DicomParsing/ParsedDicomFile.cpp	Sat Oct 13 12:17:16 2018 +0200
+++ b/Core/DicomParsing/ParsedDicomFile.cpp	Mon Oct 15 13:45:00 2018 +0200
@@ -1174,7 +1174,7 @@
     }
 
     ReplacePlainString(DICOM_TAG_PLANAR_CONFIGURATION, "0");  // Color channels are interleaved
-    ReplacePlainString(DICOM_TAG_PHOTOMETRIC_INTERPRETATION, "MONOCHROME2");
+    SetIfAbsent(DICOM_TAG_PHOTOMETRIC_INTERPRETATION, "MONOCHROME2"); // by default, greyscale images are in MONOCHROME2
 
     unsigned int bytesPerPixel = 0;
 
--- a/Core/DicomParsing/ParsedDicomFile.h	Sat Oct 13 12:17:16 2018 +0200
+++ b/Core/DicomParsing/ParsedDicomFile.h	Mon Oct 15 13:45:00 2018 +0200
@@ -147,6 +147,16 @@
       Replace(tag, utf8Value, false, DicomReplaceMode_InsertIfAbsent);
     }
 
+    void SetIfAbsent(const DicomTag& tag,
+                     const std::string& utf8Value)
+    {
+      std::string currentValue;
+      if (!GetTagValue(currentValue, tag))
+      {
+        ReplacePlainString(tag, utf8Value);
+      }
+    }
+
     void RemovePrivateTags()
     {
       RemovePrivateTagsInternal(NULL);
--- a/NEWS	Sat Oct 13 12:17:16 2018 +0200
+++ b/NEWS	Mon Oct 15 13:45:00 2018 +0200
@@ -25,7 +25,7 @@
 * New modality manufacturer: "GE" for GE Healthcare EA and AW
 * Executing a query/retrieve from the REST API now creates a job
 * Fix: Closing DICOM associations after running query/retrieve from REST API
-
+* Fix: Allow creation of MONOCHROME1 greyscale images in tools/create-dicom
 
 Version 1.4.2 (2018-09-20)
 ==========================