From 028b6f344720d2fd8f46ad112874027b0dca865d Mon Sep 17 00:00:00 2001 From: dsarrut Date: Wed, 30 Jun 2010 06:20:09 +0000 Subject: [PATCH] add possibility to display one ROI by FG value --- vv/vvBinaryImageOverlayActor.cxx | 45 +++++++++++++++++++++++++++----- vv/vvBinaryImageOverlayActor.h | 4 ++- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/vv/vvBinaryImageOverlayActor.cxx b/vv/vvBinaryImageOverlayActor.cxx index efdb191..a30206f 100644 --- a/vv/vvBinaryImageOverlayActor.cxx +++ b/vv/vvBinaryImageOverlayActor.cxx @@ -39,6 +39,9 @@ vvBinaryImageOverlayActor::vvBinaryImageOverlayActor() mImage = 0; mSlicer = 0; mColorLUT = vtkLookupTable::New(); + mForegroundValue = 1; + mBackgroundValue = 0; + m_modeBG = true; } //------------------------------------------------------------------------------ @@ -90,10 +93,31 @@ void vvBinaryImageOverlayActor::Initialize() // how many intensity ? vtkImageMapToRGBA * mOverlayMapper = vtkImageMapToRGBA::New(); mOverlayMapper->SetInput(mImage->GetVTKImages()[0]); // DS TODO : to change if it is 4D !!! - mColorLUT->SetRange(0,1); - mColorLUT->SetNumberOfTableValues(2); - mColorLUT->SetTableValue(mBackgroundValue, 0, 0, 0, 0.0); // BG - mColorLUT->SetTableValue(1, mColor[0], mColor[1], mColor[2], mAlpha); // FG + + // DD("change to nb of intensity"); + double range[2]; + mImage->GetVTKImages()[0]->GetScalarRange(range); + // DD(range[0]); +// DD(range[1]); + int n = range[1]-range[0]+1; + mColorLUT->SetRange(range[0],range[1]); + mColorLUT->SetNumberOfTableValues(n); + + // Mode BG -> all is color except BG + if (m_modeBG) { + for(int i=0; iSetTableValue(i, mColor[0], mColor[1], mColor[2], mAlpha); + } + mColorLUT->SetTableValue(mBackgroundValue, 0, 0, 0, 0.0); + } + else { + // Mode FG -> all is BG, except FG which is color + for(int i=0; iSetTableValue(i, 0, 0, 0, 0.0); + } + mColorLUT->SetTableValue(mForegroundValue, mColor[0], mColor[1], mColor[2], mAlpha); + } + mOverlayMapper->SetLookupTable(mColorLUT); vtkImageActor * mOverlayActor = vtkImageActor::New(); @@ -153,10 +177,19 @@ void vvBinaryImageOverlayActor::SetOpacity(double d) //------------------------------------------------------------------------------ -void vvBinaryImageOverlayActor::SetImage(vvImage::Pointer image, double bg) +void vvBinaryImageOverlayActor::SetImage(vvImage::Pointer image, double bg, bool modeBG) { + // DD("vvBinaryImageOverlayActor::SetImage"); + //DD(modeBG); mImage = image; - mBackgroundValue = bg; + if (modeBG) { + mBackgroundValue = bg; + m_modeBG = true; + } + else { + mForegroundValue = bg; + m_modeBG = false; + } } //------------------------------------------------------------------------------ diff --git a/vv/vvBinaryImageOverlayActor.h b/vv/vvBinaryImageOverlayActor.h index 58512ed..fedd284 100644 --- a/vv/vvBinaryImageOverlayActor.h +++ b/vv/vvBinaryImageOverlayActor.h @@ -39,7 +39,7 @@ class vvBinaryImageOverlayActor void SetSlicer(vvSlicer * slicer); void SetColor(double r, double g, double b); void SetOpacity(double d); - void SetImage(vvImage::Pointer image, double bg); + void SetImage(vvImage::Pointer image, double bg, bool modeBG=true); void Initialize(); void UpdateColor(); void UpdateSlice(int slicer, int slice); @@ -56,6 +56,8 @@ class vvBinaryImageOverlayActor std::vector mColor; double mAlpha; double mBackgroundValue; + double mForegroundValue; + bool m_modeBG; vtkLookupTable * mColorLUT; std::vector mMapperList; -- 2.47.1