ThresholdImageView.cxx

Go to the documentation of this file.
00001 
00007 #include "ThresholdImageView.h"
00008 #include <vtkImageReslice.h>
00009 #include <vtkLookupTable.h>
00010 #include <vtkImageData.h>
00011 
00012 
00013   //=========================================================================
00014   //=========================================================================
00015   //=========================================================================
00016   //=========================================================================
00017         ThresholdImageView::ThresholdImageView( )
00018   {
00019           _minValue                                     =       0;
00020           _maxValue                                     =       1000;
00021           _baseColorR                           =       1;
00022           _baseColorG                           =       0;
00023           _baseColorB                           =       0;
00024   }
00025 
00026   //=========================================================================
00027   ThresholdImageView::~ThresholdImageView()
00028   {
00029   }
00030   //=========================================================================
00031 
00032 
00033 
00034 //----------------------------------------------------------------------------
00035 void ThresholdImageView::SetminMaxValue(int min, int max)
00036 {
00037         _minValue = min;
00038         _maxValue = max;
00039 }
00040 
00041 
00042 //----------------------------------------------------------------------------
00043 void ThresholdImageView::ConfigLookupTable()  // virtual
00044 {
00045         double range[2];
00046         
00047         GetImage()->GetScalarRange(range);
00048         if (range[1]==0)
00049         {
00050                 range[1]=255;
00051         }
00052         
00053         int minTot = floor (range[0]);
00054         int maxTot = ceil (range[1]);
00055         
00056         int minVal = floor (_minValue);
00057         int maxVal = floor (_maxValue);
00058 
00059         vtkLookupTable* thresholdTable = GetThresholdTable();
00060         thresholdTable->SetNumberOfTableValues(maxTot+1);
00061         thresholdTable->SetTableRange(range); 
00062         thresholdTable->SetAlphaRange(0, 1);
00063         thresholdTable->SetValueRange(0, 1);
00064         thresholdTable->SetSaturationRange(0, 0); 
00065         thresholdTable->SetRampToLinear( );
00066 
00067         //Assign a fake color for the upper image, and set the white as transparent
00068         int i;
00069         for(i = minTot; i <= maxTot; i++)
00070         {
00071                 if( i >= minVal && i <= maxVal )
00072                 {
00073                         thresholdTable->SetTableValue(i,_baseColorR,_baseColorG,_baseColorB, 1);
00074                 }
00075                 else if( i >= minTot && i < minVal )
00076                 {
00077                         thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
00078                 }
00079                 else if( i > maxVal && i < maxTot )
00080                 {
00081                         thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
00082                 }
00083                 else
00084                 {
00085                         thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent
00086                 }
00087         } // for
00088         thresholdTable->Build( );
00089 
00090 }
00091 
00092 
00093 //----------------------------------------------------------------------------
00094 void ThresholdImageView::SetBaseColor(double r, double g, double b)
00095 {
00096         _baseColorR = r;
00097         _baseColorG = g;
00098         _baseColorB = b;
00099 }
00100 
00101 
00102 // EOF
00103 

Generated on 20 Oct 2010 for creaMaracasVisu_lib by  doxygen 1.6.1