changeset 2415:7e217a1cc63f

PixelFormat_Float32
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 02 Oct 2017 22:02:05 +0200
parents 60950e4084ae
children feb0d2dcfa9b
files Core/DicomParsing/Internals/DicomImageDecoder.cpp Core/Enumerations.cpp Core/Enumerations.h Core/Images/ImageAccessor.cpp Core/Images/ImageProcessing.cpp Core/Images/ImageProcessing.h
diffstat 6 files changed, 69 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/Core/DicomParsing/Internals/DicomImageDecoder.cpp	Mon Oct 02 15:31:20 2017 +0200
+++ b/Core/DicomParsing/Internals/DicomImageDecoder.cpp	Mon Oct 02 22:02:05 2017 +0200
@@ -703,7 +703,7 @@
       {
         // Grayscale image: Stretch its dynamics to the [0,255] range
         int64_t a, b;
-        ImageProcessing::GetMinMaxValue(a, b, *image);
+        ImageProcessing::GetMinMaxIntegerValue(a, b, *image);
 
         if (a == b)
         {
--- a/Core/Enumerations.cpp	Mon Oct 02 15:31:20 2017 +0200
+++ b/Core/Enumerations.cpp	Mon Oct 02 22:02:05 2017 +0200
@@ -753,6 +753,9 @@
       case PixelFormat_Float32:
         return "Grayscale (float 32bpp)";
 
+      case PixelFormat_Grayscale32:
+        return "Grayscale (unsigned 32bpp)";
+
       default:
         throw OrthancException(ErrorCode_ParameterOutOfRange);
     }
@@ -1334,6 +1337,7 @@
 
       case PixelFormat_RGBA32:
       case PixelFormat_BGRA32:
+      case PixelFormat_Grayscale32:
         return 4;
 
       case PixelFormat_Float32:
--- a/Core/Enumerations.h	Mon Oct 02 15:31:20 2017 +0200
+++ b/Core/Enumerations.h	Mon Oct 02 22:02:05 2017 +0200
@@ -199,8 +199,14 @@
      **/
     PixelFormat_Float32 = 6,
 
-    // This is the memory layout for Cairo
-    PixelFormat_BGRA32 = 7
+    // This is the memory layout for Cairo (internal use)
+    PixelFormat_BGRA32 = 7,
+
+    /**
+     * {summary}{Graylevel, unsigned 32bpp image.}
+     * {description}{The image is graylevel. Each pixel is unsigned and stored in 4 bytes.}
+     **/
+    PixelFormat_Grayscale32 = 8
   };
 
 
--- a/Core/Images/ImageAccessor.cpp	Mon Oct 02 15:31:20 2017 +0200
+++ b/Core/Images/ImageAccessor.cpp	Mon Oct 02 22:02:05 2017 +0200
@@ -218,6 +218,10 @@
         ToMatlabStringInternal<uint16_t>(buffer, *this);
         break;
 
+      case PixelFormat_Grayscale32:
+        ToMatlabStringInternal<uint32_t>(buffer, *this);
+        break;
+
       case PixelFormat_SignedGrayscale16:
         ToMatlabStringInternal<int16_t>(buffer, *this);
         break;
--- a/Core/Images/ImageProcessing.cpp	Mon Oct 02 15:31:20 2017 +0200
+++ b/Core/Images/ImageProcessing.cpp	Mon Oct 02 22:02:05 2017 +0200
@@ -413,6 +413,13 @@
     }
 
     if (target.GetFormat() == PixelFormat_Float32 &&
+        source.GetFormat() == PixelFormat_Grayscale32)
+    {
+      ConvertGrayscaleToFloat<uint32_t>(target, source);
+      return;
+    }
+
+    if (target.GetFormat() == PixelFormat_Float32 &&
         source.GetFormat() == PixelFormat_SignedGrayscale16)
     {
       ConvertGrayscaleToFloat<int16_t>(target, source);
@@ -579,6 +586,10 @@
         SetInternal<uint16_t>(image, value);
         return;
 
+      case PixelFormat_Grayscale32:
+        SetInternal<uint32_t>(image, value);
+        return;
+
       case PixelFormat_SignedGrayscale16:
         SetInternal<int16_t>(image, value);
         return;
@@ -664,9 +675,9 @@
   }
 
 
-  void ImageProcessing::GetMinMaxValue(int64_t& minValue,
-                                       int64_t& maxValue,
-                                       const ImageAccessor& image)
+  void ImageProcessing::GetMinMaxIntegerValue(int64_t& minValue,
+                                              int64_t& maxValue,
+                                              const ImageAccessor& image)
   {
     switch (image.GetFormat())
     {
@@ -688,6 +699,15 @@
         break;
       }
 
+      case PixelFormat_Grayscale32:
+      {
+        uint32_t a, b;
+        GetMinMaxValueInternal<uint32_t>(a, b, image);
+        minValue = a;
+        maxValue = b;
+        break;
+      }
+
       case PixelFormat_SignedGrayscale16:
       {
         int16_t a, b;
@@ -703,6 +723,28 @@
   }
 
 
+  void ImageProcessing::GetMinMaxFloatValue(float& minValue,
+                                            float& maxValue,
+                                            const ImageAccessor& image)
+  {
+    switch (image.GetFormat())
+    {
+      case PixelFormat_Float32:
+      {
+        assert(sizeof(float) == 32);
+        float a, b;
+        GetMinMaxValueInternal<float>(a, b, image);
+        minValue = a;
+        maxValue = b;
+        break;
+      }
+
+      default:
+        throw OrthancException(ErrorCode_NotImplemented);
+    }
+  }
+
+
 
   void ImageProcessing::AddConstant(ImageAccessor& image,
                                     int64_t value)
--- a/Core/Images/ImageProcessing.h	Mon Oct 02 15:31:20 2017 +0200
+++ b/Core/Images/ImageProcessing.h	Mon Oct 02 22:02:05 2017 +0200
@@ -60,9 +60,13 @@
     static void ShiftRight(ImageAccessor& target,
                            unsigned int shift);
 
-    static void GetMinMaxValue(int64_t& minValue,
-                               int64_t& maxValue,
-                               const ImageAccessor& image);
+    static void GetMinMaxIntegerValue(int64_t& minValue,
+                                      int64_t& maxValue,
+                                      const ImageAccessor& image);
+
+    static void GetMinMaxFloatValue(float& minValue,
+                                    float& maxValue,
+                                    const ImageAccessor& image);
 
     static void AddConstant(ImageAccessor& image,
                             int64_t value);