# HG changeset patch # User Sebastien Jodogne # Date 1516630579 -3600 # Node ID 58c545177c1c0f7350e5888d6c33239fb93d6515 # Parent f19194a11c1dc45a8af1df9f8cc42c0a544d6c41 optimization diff -r f19194a11c1d -r 58c545177c1c Framework/Volumes/ImageBuffer3D.cpp --- a/Framework/Volumes/ImageBuffer3D.cpp Fri Jan 19 18:12:42 2018 +0100 +++ b/Framework/Volumes/ImageBuffer3D.cpp Mon Jan 22 15:16:19 2018 +0100 @@ -422,7 +422,7 @@ } - uint8_t ImageBuffer3D::GetPixelGrayscale8(unsigned int x, + uint8_t ImageBuffer3D::GetVoxelGrayscale8(unsigned int x, unsigned int y, unsigned int z) const { @@ -439,12 +439,11 @@ } const void* p = image_.GetConstRow(y + height_ * (depth_ - 1 - z)); - return reinterpret_cast(p) [x]; } - uint16_t ImageBuffer3D::GetPixelGrayscale16(unsigned int x, + uint16_t ImageBuffer3D::GetVoxelGrayscale16(unsigned int x, unsigned int y, unsigned int z) const { @@ -461,7 +460,6 @@ } const void* p = image_.GetConstRow(y + height_ * (depth_ - 1 - z)); - return reinterpret_cast(p) [x]; } } diff -r f19194a11c1d -r 58c545177c1c Framework/Volumes/ImageBuffer3D.h --- a/Framework/Volumes/ImageBuffer3D.h Fri Jan 19 18:12:42 2018 +0100 +++ b/Framework/Volumes/ImageBuffer3D.h Mon Jan 22 15:16:19 2018 +0100 @@ -56,6 +56,16 @@ Orthanc::Image* ExtractSagittalSlice(unsigned int slice) const; + template + T GetPixelUnchecked(unsigned int x, + unsigned int y, + unsigned int z) const + { + const uint8_t* buffer = reinterpret_cast(image_.GetConstBuffer()); + const uint8_t* row = buffer + (y + height_ * (depth_ - 1 - z)) * image_.GetPitch(); + return reinterpret_cast(row) [x]; + } + public: ImageBuffer3D(Orthanc::PixelFormat format, unsigned int width, @@ -114,11 +124,25 @@ bool FitWindowingToRange(RenderStyle& style, const DicomFrameConverter& converter) const; - uint8_t GetPixelGrayscale8(unsigned int x, + uint8_t GetVoxelGrayscale8Unchecked(unsigned int x, + unsigned int y, + unsigned int z) const + { + return GetPixelUnchecked(x, y, z); + } + + uint16_t GetVoxelGrayscale16Unchecked(unsigned int x, + unsigned int y, + unsigned int z) const + { + return GetPixelUnchecked(x, y, z); + } + + uint8_t GetVoxelGrayscale8(unsigned int x, unsigned int y, unsigned int z) const; - uint16_t GetPixelGrayscale16(unsigned int x, + uint16_t GetVoxelGrayscale16(unsigned int x, unsigned int y, unsigned int z) const;