Mercurial > hg > orthanc
changeset 2645:89b789366596
Grayscale64 pixel format
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 31 May 2018 08:31:22 +0200 |
parents | 5094369664f0 |
children | 193ef9c1b731 62cc762d1fb0 |
files | Core/Enumerations.cpp Core/Enumerations.h Core/Images/ImageAccessor.cpp Core/Images/ImageProcessing.cpp Core/Images/PixelTraits.h Plugins/Engine/PluginsEnumerations.cpp Plugins/Include/orthanc/OrthancCPlugin.h |
diffstat | 7 files changed, 111 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/Core/Enumerations.cpp Mon May 28 10:54:59 2018 +0200 +++ b/Core/Enumerations.cpp Thu May 31 08:31:22 2018 +0200 @@ -759,6 +759,9 @@ case PixelFormat_Grayscale32: return "Grayscale (unsigned 32bpp)"; + case PixelFormat_Grayscale64: + return "Grayscale (unsigned 64bpp)"; + case PixelFormat_RGB48: return "RGB48"; @@ -1459,6 +1462,9 @@ case PixelFormat_RGB48: return 6; + case PixelFormat_Grayscale64: + return 8; + default: throw OrthancException(ErrorCode_ParameterOutOfRange); }
--- a/Core/Enumerations.h Mon May 28 10:54:59 2018 +0200 +++ b/Core/Enumerations.h Thu May 31 08:31:22 2018 +0200 @@ -224,7 +224,13 @@ * {description}{This format describes a color image. The pixels are stored in 6 * consecutive bytes. The memory layout is RGB.} **/ - PixelFormat_RGB48 = 9 + PixelFormat_RGB48 = 9, + + /** + * {summary}{Graylevel, unsigned 64bpp image.} + * {description}{The image is graylevel. Each pixel is unsigned and stored in 4 bytes.} + **/ + PixelFormat_Grayscale64 = 10 };
--- a/Core/Images/ImageAccessor.cpp Mon May 28 10:54:59 2018 +0200 +++ b/Core/Images/ImageAccessor.cpp Thu May 31 08:31:22 2018 +0200 @@ -222,6 +222,10 @@ ToMatlabStringInternal<uint32_t>(buffer, *this); break; + case PixelFormat_Grayscale64: + ToMatlabStringInternal<uint64_t>(buffer, *this); + break; + case PixelFormat_SignedGrayscale16: ToMatlabStringInternal<int16_t>(buffer, *this); break;
--- a/Core/Images/ImageProcessing.cpp Mon May 28 10:54:59 2018 +0200 +++ b/Core/Images/ImageProcessing.cpp Thu May 31 08:31:22 2018 +0200 @@ -705,6 +705,17 @@ } return; + case PixelFormat_Grayscale64: + if (value == 0) + { + memset(image.GetBuffer(), 0, image.GetPitch() * image.GetHeight()); + } + else + { + SetInternal<uint64_t>(image, value); + } + return; + case PixelFormat_SignedGrayscale16: if (value == 0) {
--- a/Core/Images/PixelTraits.h Mon May 28 10:54:59 2018 +0200 +++ b/Core/Images/PixelTraits.h Thu May 31 08:31:22 2018 +0200 @@ -150,6 +150,20 @@ template <> + struct PixelTraits<PixelFormat_Grayscale32> : + public IntegerPixelTraits<PixelFormat_Grayscale32, uint32_t> + { + }; + + + template <> + struct PixelTraits<PixelFormat_Grayscale64> : + public IntegerPixelTraits<PixelFormat_Grayscale64, uint64_t> + { + }; + + + template <> struct PixelTraits<PixelFormat_RGB24> { struct PixelType @@ -264,4 +278,57 @@ target.alpha_ = 255; } }; + + + template <> + struct PixelTraits<PixelFormat_Float32> + { + typedef float PixelType; + + ORTHANC_FORCE_INLINE + static PixelFormat GetPixelFormat() + { + return PixelFormat_Float32; + } + + ORTHANC_FORCE_INLINE + static void SetZero(PixelType& target) + { + target = 0.0f; + } + + ORTHANC_FORCE_INLINE + static void Copy(PixelType& target, + const PixelType& source) + { + target = source; + } + + ORTHANC_FORCE_INLINE + static bool IsEqual(const PixelType& a, + const PixelType& b) + { + float tmp = (a - b); + + if (tmp < 0) + { + tmp = -tmp; + } + + return tmp <= std::numeric_limits<float>::epsilon(); + } + + ORTHANC_FORCE_INLINE + static void FloatToPixel(PixelType& target, + float value) + { + target = value; + } + + ORTHANC_FORCE_INLINE + static float PixelToFloat(const PixelType& source) + { + return source; + } + }; }
--- a/Plugins/Engine/PluginsEnumerations.cpp Mon May 28 10:54:59 2018 +0200 +++ b/Plugins/Engine/PluginsEnumerations.cpp Thu May 31 08:31:22 2018 +0200 @@ -151,6 +151,9 @@ case PixelFormat_Grayscale32: return OrthancPluginPixelFormat_Grayscale32; + case PixelFormat_Grayscale64: + return OrthancPluginPixelFormat_Grayscale64; + case PixelFormat_Grayscale8: return OrthancPluginPixelFormat_Grayscale8; @@ -188,6 +191,9 @@ case OrthancPluginPixelFormat_Grayscale32: return PixelFormat_Grayscale32; + case OrthancPluginPixelFormat_Grayscale64: + return PixelFormat_Grayscale64; + case OrthancPluginPixelFormat_Grayscale8: return PixelFormat_Grayscale8;
--- a/Plugins/Include/orthanc/OrthancCPlugin.h Mon May 28 10:54:59 2018 +0200 +++ b/Plugins/Include/orthanc/OrthancCPlugin.h Thu May 31 08:31:22 2018 +0200 @@ -117,8 +117,8 @@ #endif #define ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER 1 -#define ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER 3 -#define ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER 2 +#define ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER 4 +#define ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER 0 #if !defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) @@ -613,6 +613,14 @@ **/ OrthancPluginPixelFormat_BGRA32 = 10, + /** + * @brief Graylevel, unsigned 64bpp image. + * + * The image is graylevel. Each pixel is unsigned and stored in + * eight bytes. + **/ + OrthancPluginPixelFormat_Grayscale64 = 11, + _OrthancPluginPixelFormat_INTERNAL = 0x7fffffff } OrthancPluginPixelFormat;