Medical Imaging Interaction Toolkit  2024.06.00
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 mitkTransferFunction_h
14 #define mitkTransferFunction_h
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 
167 
170 
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
mitkImage.h
vtkSmartPointer< vtkColorTransferFunction >
mitk::TransferFunction::m_ColorTransferFunction
vtkSmartPointer< vtkColorTransferFunction > m_ColorTransferFunction
Definition: mitkTransferFunction.h:172
mitk::Image
Image class for storing images.
Definition: mitkImage.h:69
mitk::TransferFunction::m_Min
int m_Min
Definition: mitkTransferFunction.h:175
mitk::TransferFunction::m_GradientOpacityFunction
vtkSmartPointer< vtkPiecewiseFunction > m_GradientOpacityFunction
Definition: mitkTransferFunction.h:169
mitk::TransferFunction::ControlPoints
std::vector< std::pair< double, double > > ControlPoints
Definition: mitkTransferFunction.h:58
mitkClassMacroItkParent
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:45
mitk
Find image slices visible on a given plane.
Definition: RenderingTests.dox:1
mitk::TransferFunction::m_Histogram
mitk::HistogramGenerator::HistogramType::ConstPointer m_Histogram
Definition: mitkTransferFunction.h:181
mitkHistogramGenerator.h
mitk::operator==
MITKCORE_EXPORT bool operator==(const InteractionEvent &a, const InteractionEvent &b)
MitkCoreExports.h
mitk::TransferFunction::m_ScalarOpacityFunction
vtkSmartPointer< vtkPiecewiseFunction > m_ScalarOpacityFunction
Definition: mitkTransferFunction.h:166
mitk::TransferFunction::m_Max
int m_Max
Definition: mitkTransferFunction.h:178
mitk::TransferFunction::RGBControlPoints
std::vector< std::pair< double, itk::RGBPixel< double > > > RGBControlPoints
Definition: mitkTransferFunction.h:59
mitk::HistogramGenerator::HistogramType
itk::Statistics::Histogram< double > HistogramType
Definition: mitkHistogramGenerator.h:33
mitk::TransferFunction
The TransferFunction class A wrapper class for VTK scalar opacity, gradient opacity,...
Definition: mitkTransferFunction.h:55
MITKCORE_EXPORT
#define MITKCORE_EXPORT
Definition: MitkCoreExports.h:15