]> Creatis software - clitk.git/commitdiff
Trasnparency of color maps in fusion images
authorRomulo Pinho <pinho@lyon.fnclcc.fr>
Mon, 6 Jun 2011 12:38:41 +0000 (14:38 +0200)
committerRomulo Pinho <pinho@lyon.fnclcc.fr>
Mon, 6 Jun 2011 12:38:41 +0000 (14:38 +0200)
- finer control of transparency is given through a transparency threshold

vv/qt_ui/vvOverlayPanel.ui
vv/vvMainWindow.cxx
vv/vvMainWindow.h
vv/vvOverlayPanel.cxx
vv/vvOverlayPanel.h
vv/vvSlicer.cxx
vv/vvSlicer.h
vv/vvSlicerManager.cxx
vv/vvSlicerManager.h
vv/vvToolCreatorBase.cxx

index 60a6803859eb98011b98a10c9cd2961e5c7ac997..af07fe8fd0f35a7a215193857ed36dad2ea0022f 100644 (file)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>323</width>
-    <height>447</height>
+    <width>342</width>
+    <height>480</height>
    </rect>
   </property>
   <property name="sizePolicy">
@@ -171,12 +171,12 @@ p, li { white-space: pre-wrap; }
         </item>
         <item>
          <widget class="QToolButton" name="vfColorButton">
-           <property name="styleSheet">
-            <string>
+          <property name="styleSheet">
+           <string>
               background-color: rgb(0, 255, 0);
               border: 0px;
             </string>
-           </property>
+          </property>
          </widget>
         </item>
        </layout>
@@ -330,13 +330,7 @@ p, li { white-space: pre-wrap; }
      <property name="frameShadow">
       <enum>QFrame::Raised</enum>
      </property>
-     <layout class="QGridLayout">
-      <property name="margin">
-       <number>2</number>
-      </property>
-      <property name="spacing">
-       <number>2</number>
-      </property>
+     <layout class="QGridLayout" name="gridLayout">
       <item row="0" column="0">
        <widget class="QLabel" name="label_5">
         <property name="maximumSize">
@@ -353,7 +347,7 @@ p, li { white-space: pre-wrap; }
         </property>
        </widget>
       </item>
-      <item row="0" column="1" colspan="4">
+      <item row="0" column="1" colspan="2">
        <widget class="QLabel" name="dataFusionnedLabel">
         <property name="sizePolicy">
          <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@@ -366,14 +360,14 @@ p, li { white-space: pre-wrap; }
         </property>
        </widget>
       </item>
-      <item row="1" column="0" colspan="2">
+      <item row="1" column="0" colspan="3">
        <widget class="QLabel" name="opacityLabel">
         <property name="text">
-         <string>Opacity :</string>
+         <string>Global Opacity :</string>
         </property>
        </widget>
       </item>
-      <item row="1" column="2" colspan="3">
+      <item row="1" column="3" colspan="3">
        <widget class="QSlider" name="opacityHorizontalSlider">
         <property name="sizePolicy">
          <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@@ -386,7 +380,36 @@ p, li { white-space: pre-wrap; }
         </property>
        </widget>
       </item>
-      <item row="2" column="0" colspan="2">
+      <item row="2" column="0" colspan="3">
+       <widget class="QLabel" name="thresOpacityLabel">
+        <property name="toolTip">
+         <string>All colors below the threshold will be made transparent.</string>
+        </property>
+        <property name="statusTip">
+         <string/>
+        </property>
+        <property name="whatsThis">
+         <string/>
+        </property>
+        <property name="text">
+         <string>Transparency Threshold :</string>
+        </property>
+       </widget>
+      </item>
+      <item row="2" column="3" colspan="3">
+       <widget class="QSlider" name="thresOpacityHorizontalSlider">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="orientation">
+         <enum>Qt::Horizontal</enum>
+        </property>
+       </widget>
+      </item>
+      <item row="3" column="0" colspan="2">
        <widget class="QLabel" name="label_6">
         <property name="sizePolicy">
          <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
@@ -399,10 +422,10 @@ p, li { white-space: pre-wrap; }
         </property>
        </widget>
       </item>
-      <item row="2" column="2" colspan="2">
+      <item row="3" column="2" colspan="2">
        <widget class="QComboBox" name="fusionColorMapComboBox">
         <property name="currentIndex">
-         <number>3</number>
+         <number>0</number>
         </property>
         <item>
          <property name="text">
@@ -419,6 +442,11 @@ p, li { white-space: pre-wrap; }
           <string>Cold</string>
          </property>
         </item>
+        <item>
+         <property name="text">
+          <string>Dosimetry</string>
+         </property>
+        </item>
         <item>
          <property name="text">
           <string>Full Color Range</string>
@@ -426,14 +454,14 @@ p, li { white-space: pre-wrap; }
         </item>
        </widget>
       </item>
-      <item row="3" column="0" colspan="2">
+      <item row="4" column="0" colspan="2">
        <widget class="QLabel" name="label_7">
         <property name="text">
          <string>Window :</string>
         </property>
        </widget>
       </item>
-      <item row="3" column="2">
+      <item row="4" column="2" colspan="2">
        <widget class="QDoubleSpinBox" name="windowSpinBox">
         <property name="decimals">
          <number>4</number>
@@ -452,14 +480,14 @@ p, li { white-space: pre-wrap; }
         </property>
        </widget>
       </item>
-      <item row="3" column="3">
+      <item row="4" column="4">
        <widget class="QLabel" name="label_8">
         <property name="text">
          <string>Level :</string>
         </property>
        </widget>
       </item>
-      <item row="3" column="4">
+      <item row="4" column="5">
        <widget class="QDoubleSpinBox" name="levelSpinBox">
         <property name="decimals">
          <number>4</number>
@@ -478,7 +506,7 @@ p, li { white-space: pre-wrap; }
         </property>
        </widget>
       </item>
-      <item row="4" column="0" colspan="5">
+      <item row="5" column="0" colspan="3">
        <widget class="QLabel" name="valueFusionnedLabel">
         <property name="sizePolicy">
          <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
index 8842b2d2343e0739ca204e3b7fe4435e8ff8466d..7f23d51afb3d1f208196921e8119988ff7d2ab00 100644 (file)
@@ -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);
index 35a5d90adbf2f2ca0ce3a4b6be77e0f60d4f5475..d47dacce49a837b32d8dc2cd7877bc3cdfad7fff 100644 (file)
@@ -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();
index 843e46d97598b54f108b0f1bfdd6dcae10c02315..f19e13b0cc167325b3b9b87826a91ac3a098ead9 100644 (file)
@@ -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());
 }
 
index 0b867bc27a2458d5d3fb060a07663609a4d201ee..ef0dcf1f352178b5bf9d16c194a0d0ca359f9d42 100644 (file)
@@ -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
 //====================================================================
 
index 22f0eedae4f55b95b38f306ab0838aefd0114b7a..af3f0e6d864f06ca90203c4b4419599f131dfa5a 100644 (file)
@@ -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<vtkImageMapToWindowLevelColors>::New();
+      mFusionMapper = vtkSmartPointer<vtkImageMapToColors>::New();
+    
+    vtkSmartPointer<vtkLookupTable> 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) {
index 1cdb9f4efbdf4d762a39b82615fe58305ce7e533..0536bc1e7ef38995f20918af8d53d9b0c73b93be 100644 (file)
@@ -28,6 +28,7 @@
 #include <vtkSmartPointer.h>
 #include <vtkImageViewer2.h>
 #include <vtkImageReslice.h>
+#include <vtkImageMapToColors.h>
 
 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<vtkImageMapToWindowLevelColors> mOverlayMapper;
   vtkSmartPointer<vvBlendImageActor> mOverlayActor;
   vtkSmartPointer<vtkImageReslice> mFusionReslice;
-  vtkSmartPointer<vtkImageMapToWindowLevelColors> mFusionMapper;
+  vtkSmartPointer<vtkImageMapToColors> mFusionMapper;
   vtkSmartPointer<vtkImageActor> mFusionActor;
   vtkSmartPointer<vtkCornerAnnotation> ca;
   vtkSmartPointer<vtkCursor2D> crossCursor;
index 9ff5a3cae35ce7e0e26143e1a176225a37d506e3..08d8f5ac329af1d10a29645ab93c4e779fc411b3 100644 (file)
@@ -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)
index a1b532ee29c87d4115b50151ef2a1f2d8475c9d9..a148d196e6ebdeeb175c4d7407b2276e3c77a2ff 100644 (file)
@@ -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;
index 2744dd30e7ded2496082acd0f65e69ab6e602211..50a448941e8f524c0e567191f9356fa51264ff6b 100644 (file)
@@ -22,7 +22,7 @@
 #include <QMenu>
 
 //------------------------------------------------------------------------------
-vvToolCreatorBase::vvToolCreatorBase(QString name): mExperimental(false), mAction(NULL)
+vvToolCreatorBase::vvToolCreatorBase(QString name): mAction(NULL), mExperimental(false)
 {
   mUseContextMenu = false;
   mToolName = name;