# HG changeset patch # User Sebastien Jodogne # Date 1506974525 -7200 # Node ID 7e217a1cc63f2d6c92ee8a493aacd507562eb406 # Parent 60950e4084ae78dd2d5866dc3ad9c7a715515d44 PixelFormat_Float32 diff -r 60950e4084ae -r 7e217a1cc63f Core/DicomParsing/Internals/DicomImageDecoder.cpp --- 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) { diff -r 60950e4084ae -r 7e217a1cc63f Core/Enumerations.cpp --- 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: diff -r 60950e4084ae -r 7e217a1cc63f Core/Enumerations.h --- 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 }; diff -r 60950e4084ae -r 7e217a1cc63f Core/Images/ImageAccessor.cpp --- 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(buffer, *this); break; + case PixelFormat_Grayscale32: + ToMatlabStringInternal(buffer, *this); + break; + case PixelFormat_SignedGrayscale16: ToMatlabStringInternal(buffer, *this); break; diff -r 60950e4084ae -r 7e217a1cc63f Core/Images/ImageProcessing.cpp --- 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(target, source); + return; + } + + if (target.GetFormat() == PixelFormat_Float32 && source.GetFormat() == PixelFormat_SignedGrayscale16) { ConvertGrayscaleToFloat(target, source); @@ -579,6 +586,10 @@ SetInternal(image, value); return; + case PixelFormat_Grayscale32: + SetInternal(image, value); + return; + case PixelFormat_SignedGrayscale16: SetInternal(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(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(a, b, image); + minValue = a; + maxValue = b; + break; + } + + default: + throw OrthancException(ErrorCode_NotImplemented); + } + } + + void ImageProcessing::AddConstant(ImageAccessor& image, int64_t value) diff -r 60950e4084ae -r 7e217a1cc63f Core/Images/ImageProcessing.h --- 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);