Mercurial > hg > orthanc
changeset 465:7a966b440f19
signed images to PNG
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 12 Jul 2013 11:15:27 +0200 |
parents | 5987dd8e0776 |
children | 9da3596069b8 |
files | Core/DicomFormat/DicomIntegerPixelAccessor.cpp Core/Enumerations.h Core/FileFormats/PngWriter.cpp NEWS OrthancServer/FromDcmtkBridge.cpp OrthancServer/FromDcmtkBridge.h OrthancServer/OrthancRestApi.cpp |
diffstat | 7 files changed, 20 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/Core/DicomFormat/DicomIntegerPixelAccessor.cpp Fri Jul 12 10:37:31 2013 +0200 +++ b/Core/DicomFormat/DicomIntegerPixelAccessor.cpp Fri Jul 12 11:15:27 2013 +0200 @@ -245,7 +245,8 @@ if (v & signMask_) { // Signed value - return -static_cast<int32_t>(v & mask_); + // http://en.wikipedia.org/wiki/Two%27s_complement#Subtraction_from_2N + return -static_cast<int32_t>(mask_) + static_cast<int32_t>(v & mask_) - 1; } else {
--- a/Core/Enumerations.h Fri Jul 12 10:37:31 2013 +0200 +++ b/Core/Enumerations.h Fri Jul 12 11:15:27 2013 +0200 @@ -73,7 +73,8 @@ { PixelFormat_RGB24, PixelFormat_Grayscale8, - PixelFormat_Grayscale16 + PixelFormat_Grayscale16, + PixelFormat_SignedGrayscale16 };
--- a/Core/FileFormats/PngWriter.cpp Fri Jul 12 10:37:31 2013 +0200 +++ b/Core/FileFormats/PngWriter.cpp Fri Jul 12 11:15:27 2013 +0200 @@ -146,6 +146,7 @@ break; case PixelFormat_Grayscale16: + case PixelFormat_SignedGrayscale16: pimpl_->bitDepth_ = 16; pimpl_->colorType_ = PNG_COLOR_TYPE_GRAY; break; @@ -172,6 +173,7 @@ switch (format) { case PixelFormat_Grayscale16: + case PixelFormat_SignedGrayscale16: png_set_rows(pimpl_->png_, pimpl_->info_, &pimpl_->rows_[0]); if (Toolbox::DetectEndianness() == Endianness_Little)
--- a/NEWS Fri Jul 12 10:37:31 2013 +0200 +++ b/NEWS Fri Jul 12 11:15:27 2013 +0200 @@ -14,6 +14,7 @@ Other ----- +* Access to signed images (instances/.../image-int16) * Statistics about patients, studies, series and instances * Link from anonymized to original resource in Orthanc Explorer * Fixes for Red Hat and Debian packaging
--- a/OrthancServer/FromDcmtkBridge.cpp Fri Jul 12 10:37:31 2013 +0200 +++ b/OrthancServer/FromDcmtkBridge.cpp Fri Jul 12 11:15:27 2013 +0200 @@ -1311,6 +1311,11 @@ format = PixelFormat_Grayscale16; break; + case ImageExtractionMode_Int16: + supported = true; + format = PixelFormat_SignedGrayscale16; + break; + default: supported = false; break; @@ -1362,6 +1367,10 @@ ExtractPngImageTruncate<uint16_t>(result, *accessor, format); break; + case ImageExtractionMode_Int16: + ExtractPngImageTruncate<int16_t>(result, *accessor, format); + break; + default: throw OrthancException(ErrorCode_NotImplemented); }
--- a/OrthancServer/FromDcmtkBridge.h Fri Jul 12 10:37:31 2013 +0200 +++ b/OrthancServer/FromDcmtkBridge.h Fri Jul 12 11:15:27 2013 +0200 @@ -47,7 +47,8 @@ { ImageExtractionMode_Preview, ImageExtractionMode_UInt8, - ImageExtractionMode_UInt16 + ImageExtractionMode_UInt16, + ImageExtractionMode_Int16 }; enum DicomRootLevel
--- a/OrthancServer/OrthancRestApi.cpp Fri Jul 12 10:37:31 2013 +0200 +++ b/OrthancServer/OrthancRestApi.cpp Fri Jul 12 11:15:27 2013 +0200 @@ -1662,9 +1662,11 @@ Register("/instances/{id}/frames/{frame}/preview", GetImage<ImageExtractionMode_Preview>); Register("/instances/{id}/frames/{frame}/image-uint8", GetImage<ImageExtractionMode_UInt8>); Register("/instances/{id}/frames/{frame}/image-uint16", GetImage<ImageExtractionMode_UInt16>); + Register("/instances/{id}/frames/{frame}/image-int16", GetImage<ImageExtractionMode_Int16>); Register("/instances/{id}/preview", GetImage<ImageExtractionMode_Preview>); Register("/instances/{id}/image-uint8", GetImage<ImageExtractionMode_UInt8>); Register("/instances/{id}/image-uint16", GetImage<ImageExtractionMode_UInt16>); + Register("/instances/{id}/image-int16", GetImage<ImageExtractionMode_Int16>); Register("/modalities", ListModalities); Register("/modalities/{id}", ListModalityOperations);