Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkTransferFunction.h
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef MITK_TRANSFER_FUNCTION_H_HEADER_INCLUDED
18 #define MITK_TRANSFER_FUNCTION_H_HEADER_INCLUDED
19 
20 #include "mitkHistogramGenerator.h"
21 #include "mitkImage.h"
22 #include <MitkCoreExports.h>
23 
24 #include <itkHistogram.h>
25 #include <itkObject.h>
26 #include <itkRGBPixel.h>
27 
28 #include <vtkColorTransferFunction.h>
29 #include <vtkPiecewiseFunction.h>
30 #include <vtkSmartPointer.h>
31 
32 #include <algorithm>
33 #include <set>
34 #include <vector>
35 
36 namespace mitk
37 {
59  class MITKCORE_EXPORT TransferFunction : public itk::Object
60  {
61  public:
62  typedef std::vector<std::pair<double, double>> ControlPoints;
63  typedef std::vector<std::pair<double, itk::RGBPixel<double>>> RGBControlPoints;
64 
66 
67  itkFactorylessNewMacro(Self) itkCloneMacro(Self)
68 
70  itkSetMacro(Min, int);
71 
73  itkSetMacro(Max, int);
74 
76  itkGetMacro(Min, int);
77 
79  itkGetMacro(Max, int);
80 
82  itkGetMacro(ScalarOpacityFunction, vtkPiecewiseFunction *);
83 
85  itkGetMacro(GradientOpacityFunction, vtkPiecewiseFunction *);
86 
88  itkGetMacro(ColorTransferFunction, vtkColorTransferFunction *);
89  itkSetMacro(ColorTransferFunction, vtkSmartPointer<vtkColorTransferFunction>);
90 
92  itkGetConstObjectMacro(Histogram, HistogramGenerator::HistogramType);
93 
95  void InitializeByMitkImage(const mitk::Image *image);
96 
98  void InitializeByItkHistogram(const itk::Statistics::Histogram<double> *histogram);
99 
102  void InitializeHistogram(const mitk::Image *image);
103 
106  void SetScalarOpacityPoints(TransferFunction::ControlPoints points);
107 
110  void SetGradientOpacityPoints(TransferFunction::ControlPoints points);
111 
114  void SetRGBPoints(TransferFunction::RGBControlPoints rgbpoints);
115 
117  void AddScalarOpacityPoint(double x, double value);
118 
120  void AddGradientOpacityPoint(double x, double value);
121 
123  void AddRGBPoint(double x, double r, double g, double b);
124 
126  TransferFunction::ControlPoints &GetScalarOpacityPoints();
127 
129  TransferFunction::ControlPoints &GetGradientOpacityPoints();
130 
132  TransferFunction::RGBControlPoints &GetRGBPoints();
133 
136  int RemoveScalarOpacityPoint(double x);
137 
140  int RemoveGradientOpacityPoint(double x);
141 
143  int RemoveRGBPoint(double x);
144 
146  void ClearScalarOpacityPoints();
147 
150  void ClearGradientOpacityPoints();
151 
153  void ClearRGBPoints();
154 
155  bool operator==(Self &other);
156 
157  protected:
159  virtual ~TransferFunction();
160 
161  TransferFunction(const TransferFunction &other);
162 
163  virtual itk::LightObject::Pointer InternalClone() const override;
164 
165  void PrintSelf(std::ostream &os, itk::Indent indent) const override;
166 
168  vtkSmartPointer<vtkPiecewiseFunction> m_ScalarOpacityFunction;
169 
171  vtkSmartPointer<vtkPiecewiseFunction> m_GradientOpacityFunction;
172 
174  vtkSmartPointer<vtkColorTransferFunction> m_ColorTransferFunction;
175 
177  int m_Min;
178 
180  int m_Max;
181 
183  mitk::HistogramGenerator::HistogramType::ConstPointer m_Histogram;
184 
185  private:
187  TransferFunction::ControlPoints m_ScalarOpacityPoints;
188 
190  TransferFunction::ControlPoints m_GradientOpacityPoints;
191 
193  TransferFunction::RGBControlPoints m_RGBPoints;
194  };
195 }
196 
197 #endif /* MITK_TRANSFER_FUNCTION_H_HEADER_INCLUDED */
#define MITKCORE_EXPORT
#define Max(x, y)
Definition: AnnotationP.h:41
STL namespace.
The TransferFunction class A wrapper class for VTK scalar opacity, gradient opacity, and color transfer functions.Holds a copy of each of the three standard VTK transfer functions (scalar opacity, gradient opacity, color) and provides an interface for manipulating their control points. Each original function can be retrieved by a Get() method.
DataCollection - Class to facilitate loading/accessing structured data.
std::vector< std::pair< double, itk::RGBPixel< double > > > RGBControlPoints
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:53
Image class for storing images.
Definition: mitkImage.h:76
std::vector< std::pair< double, double > > ControlPoints
Provides an easy way to calculate an itk::Histogram for a mitk::Image.
#define Min(x, y)
Definition: AnnotationP.h:38