]> Creatis software - cpPlugins.git/blob - lib/cpExtensions/Visualization/ImageBlender.h
Double click widget integrated with segmentation and deformation filters.
[cpPlugins.git] / lib / cpExtensions / Visualization / ImageBlender.h
1 #ifndef __CPEXTENSIONS__VISUALIZATION__IMAGEBLENDER__H__
2 #define __CPEXTENSIONS__VISUALIZATION__IMAGEBLENDER__H__
3
4 #include <cpExtensions/cpExtensions_Export.h>
5
6 #include <cmath>
7 #include <map>
8
9 #include <vtkThreadedImageAlgorithm.h>
10
11 namespace cpExtensions
12 {
13   namespace Visualization
14   {
15     /**
16      */
17     class cpExtensions_EXPORT ImageBlender
18       : public vtkThreadedImageAlgorithm
19     {
20     public:
21       typedef ImageBlender Self;
22       vtkTypeMacro( ImageBlender, vtkThreadedImageAlgorithm );
23
24     public:
25       static Self* New( );
26       void PrintSelf( std::ostream& os, vtkIndent indent );
27
28       unsigned int GetNumberOfImages( ) const;
29
30       const double& GetMaxWindow( ) const;
31       const double& GetMaxLevel( ) const;
32       const double& GetMinWindow( ) const;
33       const double& GetMinLevel( ) const;
34       const double& GetWindow( ) const;
35       const double& GetLevel( ) const;
36
37       void SetWindow( const double& w );
38       void SetLevel( const double& l );
39       void SetWindowLevel( const double& w, const double& l );
40
41       void GetColor(
42         const unsigned int& i,
43         double& r,
44         double& g,
45         double& b
46         ) const;
47       void SetColor(
48         const unsigned int& i,
49         const double& r,
50         const double& g,
51         const double& b
52         );
53
54     protected:
55       ImageBlender( );
56       virtual ~ImageBlender( );
57
58       int RequestInformation(
59         vtkInformation* request,
60         vtkInformationVector** inputVector,
61         vtkInformationVector* outputVector
62         );
63       void ThreadedRequestData(
64         vtkInformation* request,
65         vtkInformationVector** inputVector,
66         vtkInformationVector* outputVector,
67         vtkImageData*** inData,
68         vtkImageData** outData,
69         int outExt[ 6 ], int id
70         );
71       int FillInputPortInformation( int i, vtkInformation* info );
72
73       void _GenerateData(
74         vtkImageData** inDatas,
75         int numInputs,
76         vtkImageData* outData,
77         int outExt[6],
78         int id
79         );
80
81     private:
82       // Purposely not implemented.
83       ImageBlender( const Self& other );
84       void operator=( const Self& other );
85
86     protected:
87       struct TColor
88       {
89         double R, G, B, N;
90         TColor(
91           const double& r = double( 1 ),
92           const double& g = double( 0 ),
93           const double& b = double( 0 )
94           )
95           : R( r ),
96             G( g ),
97             B( b )
98           {
99             this->N = std::sqrt( ( r * r ) + ( g * g ) + ( b * b ) );
100           }
101       };
102       mutable std::map< unsigned int, TColor > m_Colors;
103
104       double m_MaxWindow;
105       double m_MaxLevel;
106       double m_MinWindow;
107       double m_MinLevel;
108       double m_Window;
109       double m_Level;
110
111       int    m_Extent[ 6 ];
112       double m_WLSlope;
113       double m_WLOffset;
114     };
115
116   } // ecapseman
117
118 } // ecapseman
119
120 #endif //  __CPEXTENSIONS__VISUALIZATION__IMAGEBLENDER__H__
121
122 // eof - $RCSfile$