Medical Imaging Interaction Toolkit  2021.10.99-1c4db16f
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 (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef MITK_TRANSFER_FUNCTION_H_HEADER_INCLUDED
14 #define MITK_TRANSFER_FUNCTION_H_HEADER_INCLUDED
15 
16 #include "mitkHistogramGenerator.h"
17 #include "mitkImage.h"
18 #include <MitkCoreExports.h>
19 
20 #include <itkHistogram.h>
21 #include <itkObject.h>
22 #include <itkRGBPixel.h>
23 
24 #include <vtkColorTransferFunction.h>
25 #include <vtkPiecewiseFunction.h>
26 #include <vtkSmartPointer.h>
27 
28 #include <algorithm>
29 #include <set>
30 #include <vector>
31 
32 namespace mitk
33 {
55  class MITKCORE_EXPORT TransferFunction : public itk::Object
56  {
57  public:
58  typedef std::vector<std::pair<double, double>> ControlPoints;
59  typedef std::vector<std::pair<double, itk::RGBPixel<double>>> RGBControlPoints;
60 
62 
63  itkFactorylessNewMacro(Self);
64 
65  itkCloneMacro(Self);
66 
68  itkSetMacro(Min, int);
69 
71  itkSetMacro(Max, int);
72 
74  itkGetMacro(Min, int);
75 
77  itkGetMacro(Max, int);
78 
80  itkGetMacro(ScalarOpacityFunction, vtkPiecewiseFunction *);
81 
83  itkGetMacro(GradientOpacityFunction, vtkPiecewiseFunction *);
84 
86  itkGetMacro(ColorTransferFunction, vtkColorTransferFunction *);
87  itkSetMacro(ColorTransferFunction, vtkSmartPointer<vtkColorTransferFunction>);
88 
90  itkGetConstObjectMacro(Histogram, HistogramGenerator::HistogramType);
91 
93  void InitializeByMitkImage(const mitk::Image *image);
94 
96  void InitializeByItkHistogram(const itk::Statistics::Histogram<double> *histogram);
97 
100  void InitializeHistogram(const mitk::Image *image);
101 
104  void SetScalarOpacityPoints(TransferFunction::ControlPoints points);
105 
108  void SetGradientOpacityPoints(TransferFunction::ControlPoints points);
109 
112  void SetRGBPoints(TransferFunction::RGBControlPoints rgbpoints);
113 
115  void AddScalarOpacityPoint(double x, double value);
116 
118  void AddGradientOpacityPoint(double x, double value);
119 
121  void AddRGBPoint(double x, double r, double g, double b);
122 
124  TransferFunction::ControlPoints &GetScalarOpacityPoints();
125 
127  TransferFunction::ControlPoints &GetGradientOpacityPoints();
128 
130  TransferFunction::RGBControlPoints &GetRGBPoints();
131 
134  int RemoveScalarOpacityPoint(double x);
135 
138  int RemoveGradientOpacityPoint(double x);
139 
141  int RemoveRGBPoint(double x);
142 
144  void ClearScalarOpacityPoints();
145 
148  void ClearGradientOpacityPoints();
149 
151  void ClearRGBPoints();
152 
153  bool operator==(Self &other);
154 
155  protected:
157  ~TransferFunction() override;
158 
159  TransferFunction(const TransferFunction &other);
160 
161  itk::LightObject::Pointer InternalClone() const override;
162 
163  void PrintSelf(std::ostream &os, itk::Indent indent) const override;
164 
166  vtkSmartPointer<vtkPiecewiseFunction> m_ScalarOpacityFunction;
167 
169  vtkSmartPointer<vtkPiecewiseFunction> m_GradientOpacityFunction;
170 
172  vtkSmartPointer<vtkColorTransferFunction> m_ColorTransferFunction;
173 
175  int m_Min;
176 
178  int m_Max;
179 
181  mitk::HistogramGenerator::HistogramType::ConstPointer m_Histogram;
182 
183  private:
185  TransferFunction::ControlPoints m_ScalarOpacityPoints;
186 
188  TransferFunction::ControlPoints m_GradientOpacityPoints;
189 
192  };
193 }
194 
195 #endif /* MITK_TRANSFER_FUNCTION_H_HEADER_INCLUDED */
MITKCORE_EXPORT bool operator==(const InteractionEvent &a, const InteractionEvent &b)
vtkSmartPointer< vtkColorTransferFunction > m_ColorTransferFunction
#define MITKCORE_EXPORT
vtkSmartPointer< vtkPiecewiseFunction > m_GradientOpacityFunction
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
mitk::HistogramGenerator::HistogramType::ConstPointer m_Histogram
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:45
Image class for storing images.
Definition: mitkImage.h:69
vtkSmartPointer< vtkPiecewiseFunction > m_ScalarOpacityFunction
itk::Statistics::Histogram< double > HistogramType
std::vector< std::pair< double, double > > ControlPoints