]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageView.cxx
*** empty log message ***
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / ThresholdImageView / ColorLayerImageView.cxx
1
2 /**
3  *  \file 
4  *  \brief Class bbtk::ThresholdImageView . 
5  */
6
7 #include "ColorLayerImageView.h"
8
9 #include <vtkImageReslice.h>
10 #include <vtkLookupTable.h>
11 #include <vtkImageData.h>
12
13
14   //=========================================================================
15   //=========================================================================
16   //=========================================================================
17   //=========================================================================
18         ColorLayerImageView::ColorLayerImageView( )
19   {
20   }
21
22   //=========================================================================
23   ColorLayerImageView::~ColorLayerImageView()
24   {
25   }
26   //=========================================================================
27
28
29 //----------------------------------------------------------------------------
30 void ColorLayerImageView::ConfigLookupTable()  // virtual
31 {
32         double range[2];
33         
34         GetImage()->GetScalarRange(range);
35         if (range[1]==0)
36         {
37                 range[1]=255;
38         }
39         
40         int minTot = floor (range[0]);
41         int maxTot = ceil (range[1]);
42         
43
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( );
51
52         //Assign a fake color for the upper image, and set the white as transparent
53         int i,ii;
54         double iBlue=0 , iYellow=0 , iRed=0;
55         double delta=(maxTot-minTot)/3.0;
56
57         double delta0=delta*0;
58         double delta1=delta*1;
59         double delta2=delta*2;
60         double delta3=delta*3;
61
62
63         for(i = minTot; i <= maxTot; i++)
64         {
65                 ii=i-minTot;
66                 if ((ii>=delta0) && (ii<=delta1)) // iBlue
67                 {
68                         thresholdTable->SetTableValue( i , 0 , 0 , iBlue/delta , 1);    
69                         iBlue++;
70                 }
71                 if ((ii>=delta1) && (ii<=delta2)) // iYellow
72                 {
73                         thresholdTable->SetTableValue( i , iYellow/delta , iYellow/delta , (delta-iYellow)/delta , 1);  
74                         iYellow++;
75                 }
76                 if ((ii>=delta2) && (ii<=delta3)) // iRed
77                 {
78                         thresholdTable->SetTableValue( i , 1 , (delta-iRed)/delta , 0 , 1);     
79                         iRed++;
80                 }
81         } // for
82
83         thresholdTable->Build( );
84
85 }
86
87
88
89
90 // EOF
91