Mercurial > hg > orthanc-stone
changeset 835:0965b665c653
windowing and linear interpolation in GrayscaleStyleConfigurator
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 31 May 2019 16:30:32 +0200 |
parents | c51b12fb4f34 |
children | e62e7361fd60 |
files | Framework/Scene2D/GrayscaleStyleConfigurator.cpp Framework/Scene2D/GrayscaleStyleConfigurator.h Samples/WebAssembly/BasicMPR.cpp |
diffstat | 3 files changed, 85 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/Framework/Scene2D/GrayscaleStyleConfigurator.cpp Fri May 31 15:21:50 2019 +0200 +++ b/Framework/Scene2D/GrayscaleStyleConfigurator.cpp Fri May 31 16:30:32 2019 +0200 @@ -21,12 +21,51 @@ #include "GrayscaleStyleConfigurator.h" +#include "FloatTextureSceneLayer.h" + #include <Core/OrthancException.h> namespace OrthancStone { - TextureBaseSceneLayer* GrayscaleStyleConfigurator::CreateTextureFromImage(const Orthanc::ImageAccessor& image) const + void GrayscaleStyleConfigurator::SetLinearInterpolation(bool enabled) + { + linearInterpolation_ = enabled; + revision_++; + } + + TextureBaseSceneLayer* GrayscaleStyleConfigurator::CreateTextureFromImage( + const Orthanc::ImageAccessor& image) const { throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); } + + TextureBaseSceneLayer* GrayscaleStyleConfigurator::CreateTextureFromDicom( + const Orthanc::ImageAccessor& frame, + const DicomInstanceParameters& parameters) const + { + std::auto_ptr<TextureBaseSceneLayer> layer(parameters.CreateTexture(frame)); + + if (layer.get() == NULL || + layer->GetTexture().GetFormat() != Orthanc::PixelFormat_Float32) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat); + } + else + { + return layer.release(); + } + } + + + void GrayscaleStyleConfigurator::ApplyStyle(ISceneLayer& layer) const + { + FloatTextureSceneLayer& l = dynamic_cast<FloatTextureSceneLayer&>(layer); + + l.SetLinearInterpolation(linearInterpolation_); + + if (hasWindowing_) + { + l.SetWindowing(windowing_); + } + } }
--- a/Framework/Scene2D/GrayscaleStyleConfigurator.h Fri May 31 15:21:50 2019 +0200 +++ b/Framework/Scene2D/GrayscaleStyleConfigurator.h Fri May 31 16:30:32 2019 +0200 @@ -32,14 +32,32 @@ class GrayscaleStyleConfigurator : public ILayerStyleConfigurator { private: - uint64_t revision_; + uint64_t revision_; + bool linearInterpolation_; + bool hasWindowing_; + ImageWindowing windowing_; - // TODO - Add windowing + // TODO - Add custom windowing public: GrayscaleStyleConfigurator() : - revision_(0) + revision_(0), + linearInterpolation_(false), + hasWindowing_(false) + { + } + + void SetWindowing(ImageWindowing windowing) { + hasWindowing_ = true; + windowing_ = windowing; + } + + void SetLinearInterpolation(bool enabled); + + bool IsLinearInterpolation() const + { + return linearInterpolation_; } virtual uint64_t GetRevision() const @@ -47,16 +65,13 @@ return revision_; } - virtual TextureBaseSceneLayer* CreateTextureFromImage(const Orthanc::ImageAccessor& image) const; + virtual TextureBaseSceneLayer* CreateTextureFromImage( + const Orthanc::ImageAccessor& image) const; - virtual TextureBaseSceneLayer* CreateTextureFromDicom(const Orthanc::ImageAccessor& frame, - const DicomInstanceParameters& parameters) const - { - return parameters.CreateTexture(frame); - } + virtual TextureBaseSceneLayer* CreateTextureFromDicom( + const Orthanc::ImageAccessor& frame, + const DicomInstanceParameters& parameters) const; - virtual void ApplyStyle(ISceneLayer& layer) const - { - } + virtual void ApplyStyle(ISceneLayer& layer) const; }; }
--- a/Samples/WebAssembly/BasicMPR.cpp Fri May 31 15:21:50 2019 +0200 +++ b/Samples/WebAssembly/BasicMPR.cpp Fri May 31 16:30:32 2019 +0200 @@ -370,15 +370,30 @@ loader_.reset(new OrthancStone::OrthancSeriesVolumeProgressiveLoader(ct_, oracle_, oracle_)); widget1_.reset(new OrthancStone::VolumeSlicerWidget(broker_, "mycanvas1", OrthancStone::VolumeProjection_Axial)); - widget1_->SetSlicer(0, loader_, *loader_, new OrthancStone::GrayscaleStyleConfigurator); + { + std::auto_ptr<OrthancStone::GrayscaleStyleConfigurator> style(new OrthancStone::GrayscaleStyleConfigurator); + style->SetLinearInterpolation(true); + style->SetWindowing(OrthancStone::ImageWindowing_Bone); + widget1_->SetSlicer(0, loader_, *loader_, style.release()); + } widget1_->UpdateSize(); widget2_.reset(new OrthancStone::VolumeSlicerWidget(broker_, "mycanvas2", OrthancStone::VolumeProjection_Coronal)); - widget2_->SetSlicer(0, loader_, *loader_, new OrthancStone::GrayscaleStyleConfigurator); + { + std::auto_ptr<OrthancStone::GrayscaleStyleConfigurator> style(new OrthancStone::GrayscaleStyleConfigurator); + style->SetLinearInterpolation(true); + style->SetWindowing(OrthancStone::ImageWindowing_Bone); + widget2_->SetSlicer(0, loader_, *loader_, style.release()); + } widget2_->UpdateSize(); widget3_.reset(new OrthancStone::VolumeSlicerWidget(broker_, "mycanvas3", OrthancStone::VolumeProjection_Sagittal)); - widget3_->SetSlicer(0, loader_, *loader_, new OrthancStone::GrayscaleStyleConfigurator); + { + std::auto_ptr<OrthancStone::GrayscaleStyleConfigurator> style(new OrthancStone::GrayscaleStyleConfigurator); + style->SetLinearInterpolation(true); + style->SetWindowing(OrthancStone::ImageWindowing_Bone); + widget3_->SetSlicer(0, loader_, *loader_, style.release()); + } widget3_->UpdateSize(); emscripten_set_resize_callback("#window", NULL, false, OnWindowResize);