Medical Imaging Interaction Toolkit  2025.12.02
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 
105 
109 
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 
125 
128 
131 
135 
139 
141  int RemoveRGBPoint(double x);
142 
145 
149 
152 
153  bool operator==(Self &other);
154 
155  protected:
157  ~TransferFunction() override;
158 
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
#define MITKCORE_EXPORT
itk::Statistics::Histogram< double > HistogramType
Image class for storing images.
Definition: mitkImage.h:70
The TransferFunction class A wrapper class for VTK scalar opacity, gradient opacity,...
TransferFunction(const TransferFunction &other)
int RemoveRGBPoint(double x)
Remove the specified control point from the color transfer function.
void SetScalarOpacityPoints(TransferFunction::ControlPoints points)
Insert control points and values into the scalar opacity transfer function.
void ClearGradientOpacityPoints()
Removes all control points from the gradient opacity transfer function.
mitk::HistogramGenerator::HistogramType::ConstPointer m_Histogram
TransferFunction::RGBControlPoints & GetRGBPoints()
Get a copy of the color transfer function control-points.
void InitializeByMitkImage(const mitk::Image *image)
Initialize transfer function based on the histogram of an mitk::Image.
int RemoveGradientOpacityPoint(double x)
Remove the specified control point from the gradient opacity transfer function.
TransferFunction::ControlPoints & GetGradientOpacityPoints()
Get a copy of the gradient opacity transfer function control-points.
std::vector< std::pair< double, itk::RGBPixel< double > > > RGBControlPoints
void ClearScalarOpacityPoints()
Removes all control points from the scalar opacity transfer function.
std::vector< std::pair< double, double > > ControlPoints
vtkSmartPointer< vtkPiecewiseFunction > m_GradientOpacityFunction
~TransferFunction() override
void SetRGBPoints(TransferFunction::RGBControlPoints rgbpoints)
Insert control points and RGB values into the color transfer function.
int RemoveScalarOpacityPoint(double x)
Remove the specified control point from the scalar opacity transfer function.
void SetGradientOpacityPoints(TransferFunction::ControlPoints points)
Insert control points and values into the gradient opacity transfer function.
void AddGradientOpacityPoint(double x, double value)
Add a single control point to the gradient opacity transfer function.
itk::LightObject::Pointer InternalClone() const override
TransferFunction::ControlPoints & GetScalarOpacityPoints()
Get a copy of the scalar opacity transfer function control-points.
void AddScalarOpacityPoint(double x, double value)
Add a single control point to the scalar opacity transfer function.
void AddRGBPoint(double x, double r, double g, double b)
Add a single control point to the color opacity transfer function.
void InitializeHistogram(const mitk::Image *image)
Initialize the internal histogram and min/max range based on the specified mitk::Image.
void ClearRGBPoints()
Removes all control points from the color transfer function.
void InitializeByItkHistogram(const itk::Statistics::Histogram< double > *histogram)
Initialize transfer function based on the specified histogram.
void PrintSelf(std::ostream &os, itk::Indent indent) const override
vtkSmartPointer< vtkColorTransferFunction > m_ColorTransferFunction
bool operator==(Self &other)
vtkSmartPointer< vtkPiecewiseFunction > m_ScalarOpacityFunction
#define mitkClassMacroItkParent(className, SuperClassName)
Definition: mitkCommon.h:45
Find image slices visible on a given plane.