From 8eed6bc78fb0ef451329c9aaa1df10271bda1129 Mon Sep 17 00:00:00 2001 From: Romulo Pinho Date: Mon, 6 Jun 2011 14:38:41 +0200 Subject: [PATCH] Trasnparency of color maps in fusion images - finer control of transparency is given through a transparency threshold --- vv/qt_ui/vvOverlayPanel.ui | 76 ++++++++++++++++++++++++++------------ vv/vvMainWindow.cxx | 10 +++-- vv/vvMainWindow.h | 2 +- vv/vvOverlayPanel.cxx | 9 ++++- vv/vvOverlayPanel.h | 4 +- vv/vvSlicer.cxx | 11 +++++- vv/vvSlicer.h | 5 ++- vv/vvSlicerManager.cxx | 43 ++++++++++++++++----- vv/vvSlicerManager.h | 7 ++++ vv/vvToolCreatorBase.cxx | 2 +- 10 files changed, 122 insertions(+), 47 deletions(-) diff --git a/vv/qt_ui/vvOverlayPanel.ui b/vv/qt_ui/vvOverlayPanel.ui index 60a6803..af07fe8 100644 --- a/vv/qt_ui/vvOverlayPanel.ui +++ b/vv/qt_ui/vvOverlayPanel.ui @@ -6,8 +6,8 @@ 0 0 - 323 - 447 + 342 + 480 @@ -171,12 +171,12 @@ p, li { white-space: pre-wrap; } - - + + background-color: rgb(0, 255, 0); border: 0px; - + @@ -330,13 +330,7 @@ p, li { white-space: pre-wrap; } QFrame::Raised - - - 2 - - - 2 - + @@ -353,7 +347,7 @@ p, li { white-space: pre-wrap; } - + @@ -366,14 +360,14 @@ p, li { white-space: pre-wrap; } - + - Opacity : + Global Opacity : - + @@ -386,7 +380,36 @@ p, li { white-space: pre-wrap; } - + + + + All colors below the threshold will be made transparent. + + + + + + + + + Transparency Threshold : + + + + + + + + 0 + 0 + + + + Qt::Horizontal + + + + @@ -399,10 +422,10 @@ p, li { white-space: pre-wrap; } - + - 3 + 0 @@ -419,6 +442,11 @@ p, li { white-space: pre-wrap; } Cold + + + Dosimetry + + Full Color Range @@ -426,14 +454,14 @@ p, li { white-space: pre-wrap; } - + Window : - + 4 @@ -452,14 +480,14 @@ p, li { white-space: pre-wrap; } - + Level : - + 4 @@ -478,7 +506,7 @@ p, li { white-space: pre-wrap; } - + diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 8842b2d..7f23d51 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -290,8 +290,8 @@ vvMainWindow::vvMainWindow():vvMainWindowBase() connect(linkPanel,SIGNAL(removeLink(QString,QString)),this,SLOT(RemoveLink(QString,QString))); connect(overlayPanel,SIGNAL(VFPropertyUpdated(int,int,int,int,double,double,double)),this,SLOT(SetVFProperty(int,int,int,int,double,double,double))); connect(overlayPanel,SIGNAL(OverlayPropertyUpdated(int)),this,SLOT(SetOverlayProperty(int))); - connect(overlayPanel,SIGNAL(FusionPropertyUpdated(int,int,double,double)), - this,SLOT(SetFusionProperty(int,int,double,double))); + connect(overlayPanel,SIGNAL(FusionPropertyUpdated(int,int,int,double,double)), + this,SLOT(SetFusionProperty(int,int,int,double,double))); connect(landmarksPanel,SIGNAL(UpdateRenderWindows()),this,SLOT(UpdateRenderWindows())); playMode = 0;//pause @@ -1168,12 +1168,13 @@ void vvMainWindow::ImageInfoChanged() if (mSlicerManagers[index]->GetSlicer(0)->GetFusion()) { overlayPanel->getFusionName(mSlicerManagers[index]->GetFusionName().c_str()); overlayPanel->getFusionProperty(mSlicerManagers[index]->GetFusionOpacity(), + mSlicerManagers[index]->GetFusionThresholdOpacity(), mSlicerManagers[index]->GetFusionColorMap(), mSlicerManagers[index]->GetFusionWindow(), mSlicerManagers[index]->GetFusionLevel()); } else { overlayPanel->getFusionName(mSlicerManagers[index]->GetFusionName().c_str()); - overlayPanel->getFusionProperty(-1, -1,-1,-1); + overlayPanel->getFusionProperty(-1, -1, -1, -1, -1); } } } @@ -2140,11 +2141,12 @@ void vvMainWindow::SetOverlayProperty(int color) //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -void vvMainWindow::SetFusionProperty(int opacity, int colormap,double window, double level) +void vvMainWindow::SetFusionProperty(int opacity, int thresOpacity, int colormap,double window, double level) { int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]); if (mSlicerManagers[index]->GetSlicer(0)->GetFusion()) { mSlicerManagers[index]->SetFusionOpacity(opacity); + mSlicerManagers[index]->SetFusionThresholdOpacity(thresOpacity); mSlicerManagers[index]->SetFusionColorMap(colormap); mSlicerManagers[index]->SetFusionWindow(window); mSlicerManagers[index]->SetFusionLevel(level); diff --git a/vv/vvMainWindow.h b/vv/vvMainWindow.h index 35a5d90..d47dacc 100644 --- a/vv/vvMainWindow.h +++ b/vv/vvMainWindow.h @@ -143,7 +143,7 @@ public slots: void SetVFProperty(int subsampling,int scale,int lut, int width, double r, double g, double b); void SetOverlayProperty(int color); - void SetFusionProperty(int opacity,int colormap,double window,double level); + void SetFusionProperty(int opacity, int tresOpacity, int colormap,double window,double level); void GoToCursor(); void PlayPause(); diff --git a/vv/vvOverlayPanel.cxx b/vv/vvOverlayPanel.cxx index 843e46d..f19e13b 100644 --- a/vv/vvOverlayPanel.cxx +++ b/vv/vvOverlayPanel.cxx @@ -45,6 +45,7 @@ vvOverlayPanel::vvOverlayPanel(QWidget * parent):QWidget(parent) connect(vfColorButton,SIGNAL(clicked()),this,SLOT(VFColorChangeRequest())); connect(colorHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(setOverlayProperty())); connect(opacityHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(setFusionProperty())); + connect(thresOpacityHorizontalSlider,SIGNAL(valueChanged(int)),this,SLOT(setFusionProperty())); connect(fusionColorMapComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(setFusionProperty())); connect(windowSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty())); connect(levelSpinBox,SIGNAL(valueChanged(double)),this,SLOT(setFusionProperty())); @@ -163,13 +164,15 @@ void vvOverlayPanel::getFusionName(QString name) dataFusionnedLabel->setText(filename.toStdString().c_str()); } -void vvOverlayPanel::getFusionProperty(int opacity, int colormap, double window, double level) +void vvOverlayPanel::getFusionProperty(int opacity, int thresOpacity, int colormap, double window, double level) { if (opacity > -1) { fusionFrame->show(); fusionFrame->setEnabled(1); opacityHorizontalSlider->setEnabled(1); opacityHorizontalSlider->setValue(opacity); + thresOpacityHorizontalSlider->setEnabled(1); + thresOpacityHorizontalSlider->setValue(thresOpacity); fusionColorMapComboBox->setEnabled(1); fusionColorMapComboBox->setCurrentIndex(colormap); windowSpinBox->setEnabled(1); @@ -181,6 +184,8 @@ void vvOverlayPanel::getFusionProperty(int opacity, int colormap, double window, fusionFrame->setEnabled(0); opacityHorizontalSlider->setEnabled(0); opacityHorizontalSlider->setValue(0); + thresOpacityHorizontalSlider->setEnabled(0); + thresOpacityHorizontalSlider->setValue(0); fusionColorMapComboBox->setEnabled(0); fusionColorMapComboBox->setCurrentIndex(-1); windowSpinBox->setEnabled(0); @@ -190,7 +195,7 @@ void vvOverlayPanel::getFusionProperty(int opacity, int colormap, double window, void vvOverlayPanel::setFusionProperty() { - emit FusionPropertyUpdated(opacityHorizontalSlider->value(), fusionColorMapComboBox->currentIndex(), + emit FusionPropertyUpdated(opacityHorizontalSlider->value(), thresOpacityHorizontalSlider->value(), fusionColorMapComboBox->currentIndex(), windowSpinBox->value(), levelSpinBox->value()); } diff --git a/vv/vvOverlayPanel.h b/vv/vvOverlayPanel.h index 0b867bc..ef0dcf1 100644 --- a/vv/vvOverlayPanel.h +++ b/vv/vvOverlayPanel.h @@ -41,7 +41,7 @@ public: void getOverlayProperty(int color); void getOverlayName(QString name); - void getFusionProperty(int opacity, int colormap, double window, double level); + void getFusionProperty(int opacity, int thresOpacity, int colormap, double window, double level); void getFusionName(QString name); void getCurrentVectorInfo(int visibility, double x, double y, double z, double value); @@ -57,7 +57,7 @@ public slots: signals: void VFPropertyUpdated(int subsampling, int scale, int log, int width, double r, double g, double b); void OverlayPropertyUpdated(int color); - void FusionPropertyUpdated(int opacity, int colormap, double window, double level); + void FusionPropertyUpdated(int opacity, int thresOpacity, int colormap, double window, double level); }; // end class vvOverlayPanel //==================================================================== diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index 22f0eed..af3f0e6 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -172,7 +172,7 @@ vvBlendImageActor* vvSlicer::GetOverlayActor() //------------------------------------------------------------------------------ -vtkImageMapToWindowLevelColors* vvSlicer::GetFusionMapper() +vtkImageMapToColors* vvSlicer::GetFusionMapper() { return mFusionMapper.GetPointer(); } @@ -408,7 +408,14 @@ void vvSlicer::SetFusion(vvImage::Pointer fusion) mFusionReslice->SetInput(0, mFusion->GetFirstVTKImageData()); if (!mFusionMapper) - mFusionMapper = vtkSmartPointer::New(); + mFusionMapper = vtkSmartPointer::New(); + + vtkSmartPointer lut = vtkLookupTable::New(); + lut->SetRange(0, 1); + lut->SetValueRange(0, 1); + lut->SetSaturationRange(0, 0); + lut->Build(); + mFusionMapper->SetLookupTable(lut); mFusionMapper->SetInput(mFusionReslice->GetOutput()); if (!mFusionActor) { diff --git a/vv/vvSlicer.h b/vv/vvSlicer.h index 1cdb9f4..0536bc1 100644 --- a/vv/vvSlicer.h +++ b/vv/vvSlicer.h @@ -28,6 +28,7 @@ #include #include #include +#include class vtkActor; class vtkActor2D; @@ -70,7 +71,7 @@ public: } vtkImageMapToWindowLevelColors* GetOverlayMapper(); vvBlendImageActor* GetOverlayActor() ; - vtkImageMapToWindowLevelColors* GetFusionMapper() ; + vtkImageMapToColors* GetFusionMapper() ; vtkImageActor* GetFusionActor() ; vtkActor* GetVFActor() ; vtkCornerAnnotation* GetAnnotation(); @@ -201,7 +202,7 @@ protected: vtkSmartPointer mOverlayMapper; vtkSmartPointer mOverlayActor; vtkSmartPointer mFusionReslice; - vtkSmartPointer mFusionMapper; + vtkSmartPointer mFusionMapper; vtkSmartPointer mFusionActor; vtkSmartPointer ca; vtkSmartPointer crossCursor; diff --git a/vv/vvSlicerManager.cxx b/vv/vvSlicerManager.cxx index 9ff5a3c..08d8f5a 100644 --- a/vv/vvSlicerManager.cxx +++ b/vv/vvSlicerManager.cxx @@ -58,6 +58,7 @@ vvSlicerManager::vvSlicerManager(int numberOfSlicers) mOverlayColor = 130; mFusionOpacity = 70; + mFusionThresOpacity = 1; mFusionColorMap = 3; mFusionWindow = 1000; mFusionLevel = 1000; @@ -292,6 +293,7 @@ bool vvSlicerManager::SetFusion(std::string filename,int dim, std::string compon double *fusRange = mFusionReader->GetOutput()->GetVTKImages()[0]->GetScalarRange(); mFusionLevel = (fusRange[0]+fusRange[1])/2; mFusionWindow = fusRange[1]-fusRange[0]; + return true; } //---------------------------------------------------------------------------- @@ -1100,26 +1102,50 @@ void vvSlicerManager::SetColorMap(int colormap) LUT->SetTableRange(level-fabs(window)/4,level+fabs(window)/4); LUT->Build(); } - vtkLookupTable* fusLUT = NULL; - if (mSlicers[0]->GetFusion()) { - fusLUT = vtkLookupTable::New(); + vtkWindowLevelLookupTable* fusLUT = NULL; + if (mSlicers[0]->GetFusion()) { // && mFusionColorMap != 0) { + fusLUT = vtkWindowLevelLookupTable::New(); double fusRange [2]; fusRange[0] = mFusionLevel - mFusionWindow/2; fusRange[1] = mFusionLevel + mFusionWindow/2; - fusLUT->SetTableRange(fusRange[0],fusRange[1]); + double* frange = mFusionReader->GetOutput()->GetVTKImages()[0]->GetScalarRange(); + fusLUT->SetTableRange(frange); fusLUT->SetValueRange(1,1); fusLUT->SetSaturationRange(1,1); + fusLUT->SetAlphaRange(1, 1); + fusLUT->SetWindow(mFusionWindow); + fusLUT->SetLevel(mFusionLevel); if (mFusionColorMap == 1) fusLUT->SetHueRange(0,0.18); else if (mFusionColorMap == 2) fusLUT->SetHueRange(0.4,0.80); else if (mFusionColorMap == 3) + { + fusLUT->SetHueRange(0.666, 0); + fusLUT->SetValueRange(0.5, 1); + } + else if (mFusionColorMap == 4) fusLUT->SetHueRange(0,1); - fusLUT->Build(); - if (mFusionColorMap == 0) - fusLUT = NULL; + else if (mFusionColorMap == 0) + { + fusLUT->SetValueRange(0,1); + fusLUT->SetSaturationRange(0,0); + } + + fusLUT->ForceBuild(); + + // set color table transparancy + double alpha_range_end = frange[0] + (double)mFusionThresOpacity*(frange[1] - frange[0])/100; + for (double i = frange[0]; i < alpha_range_end; i++) { + double v[4]; + vtkIdType index = fusLUT->GetIndex(i); + fusLUT->GetTableValue(index, v); + v[3] = 0; + fusLUT->SetTableValue(index, v); + } } for ( unsigned int i = 0; i < mSlicers.size(); i++) { + if (mSlicers[i]->GetOverlay()) { vtkLookupTable* supLUT = vtkLookupTable::New(); supLUT->SetTableRange(range[0],range[1]); @@ -1146,11 +1172,10 @@ void vvSlicerManager::SetColorMap(int colormap) } else { mSlicers[i]->GetWindowLevel()->SetLookupTable(LUT); } + if (mSlicers[i]->GetFusion()) { mSlicers[i]->GetFusionActor()->SetOpacity(double(mFusionOpacity)/100); mSlicers[i]->GetFusionMapper()->SetLookupTable(fusLUT); - mSlicers[i]->GetFusionMapper()->SetWindow(mFusionWindow); - mSlicers[i]->GetFusionMapper()->SetLevel(mFusionLevel); } } if (fusLUT) diff --git a/vv/vvSlicerManager.h b/vv/vvSlicerManager.h index a1b532e..a148d19 100644 --- a/vv/vvSlicerManager.h +++ b/vv/vvSlicerManager.h @@ -121,6 +121,9 @@ class vvSlicerManager : public QObject { void SetFusionOpacity(int opacity) { mFusionOpacity = opacity; } + void SetFusionThresholdOpacity(int thresOpacity) { + mFusionThresOpacity = thresOpacity; + } void SetFusionColorMap(int colorMap) { mFusionColorMap = colorMap; } @@ -146,6 +149,9 @@ class vvSlicerManager : public QObject { int GetFusionOpacity() { return mFusionOpacity; } + int GetFusionThresholdOpacity() { + return mFusionThresOpacity; + } int GetFusionColorMap() { return mFusionColorMap; } @@ -230,6 +236,7 @@ protected: int mOverlayColor; int mFusionOpacity; + int mFusionThresOpacity; int mFusionColorMap; double mFusionWindow; double mFusionLevel; diff --git a/vv/vvToolCreatorBase.cxx b/vv/vvToolCreatorBase.cxx index 2744dd3..50a4489 100644 --- a/vv/vvToolCreatorBase.cxx +++ b/vv/vvToolCreatorBase.cxx @@ -22,7 +22,7 @@ #include //------------------------------------------------------------------------------ -vvToolCreatorBase::vvToolCreatorBase(QString name): mExperimental(false), mAction(NULL) +vvToolCreatorBase::vvToolCreatorBase(QString name): mAction(NULL), mExperimental(false) { mUseContextMenu = false; mToolName = name; -- 2.45.1