4 * \brief Class bbtk::ThresholdImageView .
7 #include "ColorLayerImageView.h"
9 #include <vtkImageReslice.h>
10 #include <vtkLookupTable.h>
11 #include <vtkImageData.h>
14 //=========================================================================
15 //=========================================================================
16 //=========================================================================
17 //=========================================================================
18 ColorLayerImageView::ColorLayerImageView( )
22 //=========================================================================
23 ColorLayerImageView::~ColorLayerImageView()
26 //=========================================================================
29 //----------------------------------------------------------------------------
30 void ColorLayerImageView::ConfigLookupTable() // virtual
34 GetImage()->GetScalarRange(range);
40 int minTot = floor (range[0]);
41 int maxTot = ceil (range[1]);
44 vtkLookupTable* thresholdTable = GetThresholdTable();
45 thresholdTable->SetNumberOfTableValues(maxTot+1);
46 thresholdTable->SetTableRange(range);
47 thresholdTable->SetAlphaRange(0, 1);
48 thresholdTable->SetValueRange(0, 1);
49 thresholdTable->SetSaturationRange(0, 0);
50 thresholdTable->SetRampToLinear( );
52 //Assign a fake color for the upper image, and set the white as transparent
54 double iBlue=0 , iYellow=0 , iRed=0;
55 double delta=(maxTot-minTot)/3.0;
57 double delta0=delta*0;
58 double delta1=delta*1;
59 double delta2=delta*2;
60 double delta3=delta*3;
63 for(i = minTot; i <= maxTot; i++)
66 if ((ii>=delta0) && (ii<=delta1)) // iBlue
68 thresholdTable->SetTableValue( i , 0 , 0 , iBlue/delta , 1);
71 if ((ii>=delta1) && (ii<=delta2)) // iYellow
73 thresholdTable->SetTableValue( i , iYellow/delta , iYellow/delta , (delta-iYellow)/delta , 1);
76 if ((ii>=delta2) && (ii<=delta3)) // iRed
78 thresholdTable->SetTableValue( i , 1 , (delta-iRed)/delta , 0 , 1);
83 thresholdTable->Build( );