Mercurial > hg > orthanc-stone
changeset 1919:ed4831e08961
added DicomInstanceParameters::CreateOverlayTexture()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 21 Mar 2022 15:50:29 +0100 |
parents | fc6009c43bd9 |
children | 05f0327d26c8 |
files | OrthancStone/Sources/Scene2D/LookupTableTextureSceneLayer.cpp OrthancStone/Sources/Toolbox/DicomInstanceParameters.cpp OrthancStone/Sources/Toolbox/DicomInstanceParameters.h |
diffstat | 3 files changed, 47 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancStone/Sources/Scene2D/LookupTableTextureSceneLayer.cpp Mon Mar 21 12:12:25 2022 +0100 +++ b/OrthancStone/Sources/Scene2D/LookupTableTextureSceneLayer.cpp Mon Mar 21 15:50:29 2022 +0100 @@ -33,13 +33,14 @@ LookupTableTextureSceneLayer::LookupTableTextureSceneLayer(const Orthanc::ImageAccessor& texture) : applyLog_(false) { + if (texture.GetFormat() == Orthanc::PixelFormat_Float32) + { + SetTexture(Orthanc::Image::Clone(texture)); + } + else { std::unique_ptr<Orthanc::ImageAccessor> t( - new Orthanc::Image(Orthanc::PixelFormat_Float32, - texture.GetWidth(), - texture.GetHeight(), - false)); - + new Orthanc::Image(Orthanc::PixelFormat_Float32, texture.GetWidth(), texture.GetHeight(), false)); Orthanc::ImageProcessing::Convert(*t, texture); SetTexture(t.release()); }
--- a/OrthancStone/Sources/Toolbox/DicomInstanceParameters.cpp Mon Mar 21 12:12:25 2022 +0100 +++ b/OrthancStone/Sources/Toolbox/DicomInstanceParameters.cpp Mon Mar 21 15:50:29 2022 +0100 @@ -569,8 +569,8 @@ } - TextureBaseSceneLayer* DicomInstanceParameters::CreateTexture - (const Orthanc::ImageAccessor& pixelData) const + TextureBaseSceneLayer* DicomInstanceParameters::CreateTexture( + const Orthanc::ImageAccessor& pixelData) const { // { // const Orthanc::ImageAccessor& source = pixelData; @@ -647,23 +647,49 @@ } - LookupTableTextureSceneLayer* DicomInstanceParameters::CreateLookupTableTexture - (const Orthanc::ImageAccessor& pixelData) const + LookupTableTextureSceneLayer* DicomInstanceParameters::CreateLookupTableTexture( + const Orthanc::ImageAccessor& pixelData) const { - std::unique_ptr<FloatTextureSceneLayer> texture; - + std::unique_ptr<LookupTableTextureSceneLayer> texture; + if (pixelData.GetFormat() == Orthanc::PixelFormat_Float32) { - return new LookupTableTextureSceneLayer(pixelData); + texture.reset(new LookupTableTextureSceneLayer(pixelData)); } else { std::unique_ptr<Orthanc::ImageAccessor> converted(ConvertToFloat(pixelData)); - return new LookupTableTextureSceneLayer(*converted); + texture.reset(new LookupTableTextureSceneLayer(*converted)); } + + if (HasPixelSpacing()) + { + texture->SetPixelSpacing(GetPixelSpacingX(), GetPixelSpacingY()); + } + + return texture.release(); } + LookupTableTextureSceneLayer* DicomInstanceParameters::CreateOverlayTexture( + int originX, + int originY, + const Orthanc::ImageAccessor& overlay) const + { + if (overlay.GetFormat() != Orthanc::PixelFormat_Grayscale8) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat); + } + + std::unique_ptr<LookupTableTextureSceneLayer> texture(CreateLookupTableTexture(overlay)); + + texture->SetOrigin(static_cast<double>(originX - 1) * texture->GetPixelSpacingX(), + static_cast<double>(originY - 1) * texture->GetPixelSpacingY()); + + return texture.release(); + } + + unsigned int DicomInstanceParameters::GetIndexInSeries() const { if (data_.hasIndexInSeries_)
--- a/OrthancStone/Sources/Toolbox/DicomInstanceParameters.h Mon Mar 21 12:12:25 2022 +0100 +++ b/OrthancStone/Sources/Toolbox/DicomInstanceParameters.h Mon Mar 21 15:50:29 2022 +0100 @@ -202,6 +202,13 @@ LookupTableTextureSceneLayer* CreateLookupTableTexture(const Orthanc::ImageAccessor& pixelData) const; + // NB: According to the DICOM standard, the top-left pixel has + // (originX, originY) equals to (1,1): + // https://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.9.2.html + LookupTableTextureSceneLayer* CreateOverlayTexture(int originX, + int originY, + const Orthanc::ImageAccessor& overlay) const; + bool HasIndexInSeries() const { return data_.hasIndexInSeries_;