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( )
24 //=========================================================================
25 ColorLayerImageView::~ColorLayerImageView()
28 //=========================================================================
31 //----------------------------------------------------------------------------
32 void ColorLayerImageView::SetSliceFixDinamic(bool fix_dinamic)
34 _fix_dinamic = fix_dinamic;
37 //----------------------------------------------------------------------------
38 void ColorLayerImageView::SetZ2(int z2)
43 //----------------------------------------------------------------------------
44 int ColorLayerImageView::GetZ() // virtual
47 if (_fix_dinamic==false)
51 result = LayerImageBase::GetZ();
58 //----------------------------------------------------------------------------
59 void ColorLayerImageView::ConfigLookupTable() // virtual
63 GetImage()->GetScalarRange(range);
69 int minTot = floor (range[0]);
70 int maxTot = ceil (range[1]);
73 vtkLookupTable* thresholdTable = GetThresholdTable();
74 thresholdTable->SetNumberOfTableValues(maxTot+1);
75 thresholdTable->SetTableRange(range);
76 thresholdTable->SetAlphaRange(0, 1);
77 thresholdTable->SetValueRange(0, 1);
78 thresholdTable->SetSaturationRange(0, 0);
79 thresholdTable->SetRampToLinear( );
81 //Assign a fake color for the upper image, and set the white as transparent
83 double iBlue=0 , iYellow=0 , iRed=0;
84 double delta=(maxTot-minTot)/3.0;
86 double delta0=delta*0;
87 double delta1=delta*1;
88 double delta2=delta*2;
89 double delta3=delta*3;
92 for(i = minTot; i <= maxTot; i++)
95 if ((ii>=delta0) && (ii<=delta1)) // iBlue
97 thresholdTable->SetTableValue( i , 0 , 0 , iBlue/delta , 1);
100 thresholdTable->SetTableValue( i , 0 , 0 , iBlue/delta , 0);
102 thresholdTable->SetTableValue( i , 0 , 0 , iBlue/delta , 1);
106 if ((ii>=delta1) && (ii<=delta2)) // iYellow
108 thresholdTable->SetTableValue( i , iYellow/delta , iYellow/delta , (delta-iYellow)/delta , 1);
111 if ((ii>=delta2) && (ii<=delta3)) // iRed
113 thresholdTable->SetTableValue( i , 1 , (delta-iRed)/delta , 0 , 1);
118 thresholdTable->Build( );