Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::TransferFunction Class Reference

Wrapper for VTK scalar opacity, gradient opacity, and color transfer functions. More...

#include <mitkTransferFunction.h>

Inheritance diagram for mitk::TransferFunction:
Collaboration diagram for mitk::TransferFunction:

Public Types

typedef std::vector< std::pair< double, double > > ControlPoints
 Type for scalar opacity or gradient opacity control points (x, value). More...
 
typedef std::vector< std::pair< double, itk::RGBPixel< double > > > RGBControlPoints
 Type for color transfer function control points (x, RGB). More...
 

Public Member Functions

 mitkClassMacroItkParent (TransferFunction, itk::DataObject)
 
Pointer Clone () const
 
virtual void SetMin (int _arg)
 Get/Set min/max of transfer function range for initialization. More...
 
virtual void SetMax (int _arg)
 Get/Set min/max of transfer function range for initialization. More...
 
virtual int GetMin ()
 Get/Set min/max of transfer function range for initialization. More...
 
virtual int GetMax ()
 Get/Set min/max of transfer function range for initialization. More...
 
virtual vtkPiecewiseFunction * GetScalarOpacityFunction ()
 Get/Set wrapped vtk transfer function. More...
 
virtual vtkPiecewiseFunction * GetGradientOpacityFunction ()
 Get/Set wrapped vtk transfer function. More...
 
virtual vtkColorTransferFunction * GetColorTransferFunction ()
 Get/Set wrapped vtk transfer function. More...
 
virtual void SetColorTransferFunction (vtkSmartPointer< vtkColorTransferFunction > _arg)
 
virtual const HistogramGenerator::HistogramType * GetHistogram ()
 Get histogram used for transfer function initialization. More...
 
void InitializeByMitkImage (const mitk::Image *image)
 Initialize all three transfer functions from an mitk::Image histogram. More...
 
void InitializeByItkHistogram (const itk::Statistics::Histogram< double > *histogram)
 Initialize all three transfer functions from an ITK histogram. More...
 
void InitializeHistogram (const mitk::Image *image)
 Compute and store the histogram and min/max range from an image. More...
 
void SetScalarOpacityPoints (TransferFunction::ControlPoints points)
 Replace all scalar opacity control points. More...
 
void SetGradientOpacityPoints (TransferFunction::ControlPoints points)
 Replace all gradient opacity control points. More...
 
void SetRGBPoints (TransferFunction::RGBControlPoints rgbpoints)
 Replace all color transfer function control points. More...
 
void AddScalarOpacityPoint (double x, double value)
 Add a single control point to the scalar opacity function. More...
 
void AddGradientOpacityPoint (double x, double value)
 Add a single control point to the gradient opacity function. More...
 
void AddRGBPoint (double x, double r, double g, double b)
 Add a single control point to the color transfer function. More...
 
TransferFunction::ControlPoints & GetScalarOpacityPoints ()
 Get the scalar opacity control points. More...
 
TransferFunction::ControlPoints & GetGradientOpacityPoints ()
 Get the gradient opacity control points. More...
 
TransferFunction::RGBControlPoints & GetRGBPoints ()
 Get the color transfer function control points. More...
 
int RemoveScalarOpacityPoint (double x)
 Remove a control point from the scalar opacity function. More...
 
int RemoveGradientOpacityPoint (double x)
 Remove a control point from the gradient opacity function. More...
 
int RemoveRGBPoint (double x)
 Remove a control point from the color transfer function. More...
 
void ClearScalarOpacityPoints ()
 Remove all control points from the scalar opacity function. More...
 
void ClearGradientOpacityPoints ()
 Remove all control points from the gradient opacity function. More...
 
void ClearRGBPoints ()
 Remove all control points from the color transfer function. More...
 
bool operator== (Self &other)
 Compare two TransferFunction objects for equality. More...
 

Static Public Member Functions

static Pointer New ()
 

Protected Member Functions

 TransferFunction ()
 
 ~TransferFunction () override
 
 TransferFunction (const Self &other)
 
 mitkCloneMacro (Self)
 
void PrintSelf (std::ostream &os, itk::Indent indent) const override
 

Protected Attributes

vtkSmartPointer< vtkPiecewiseFunction > m_ScalarOpacityFunction
 
vtkSmartPointer< vtkPiecewiseFunction > m_GradientOpacityFunction
 
vtkSmartPointer< vtkColorTransferFunction > m_ColorTransferFunction
 
int m_Min
 
int m_Max
 
mitk::HistogramGenerator::HistogramType::ConstPointer m_Histogram
 

Detailed Description

Wrapper for VTK scalar opacity, gradient opacity, and color transfer functions.

Holds and manages three standard VTK transfer functions: scalar opacity (vtkPiecewiseFunction), gradient opacity (vtkPiecewiseFunction), and color (vtkColorTransferFunction). Provides an interface for adding, removing, and querying control points, as well as initialization from image histograms.

Note
If you want to use this as a property for an mitk::Image, wrap it in a mitk::TransferFunctionProperty and set mitk::RenderingModeProperty to a mode that supports transfer functions (e.g. COLORTRANSFERFUNCTION_COLOR). See the test mitkImageVtkMapper2DTransferFunctionTest.cpp for an example.
See also
TransferFunctionProperty, RenderingModeProperty, LookupTable

Definition at line 49 of file mitkTransferFunction.h.

Member Typedef Documentation

◆ ControlPoints

typedef std::vector<std::pair<double, double> > mitk::TransferFunction::ControlPoints

Type for scalar opacity or gradient opacity control points (x, value).

Definition at line 53 of file mitkTransferFunction.h.

◆ RGBControlPoints

typedef std::vector<std::pair<double, itk::RGBPixel<double> > > mitk::TransferFunction::RGBControlPoints

Type for color transfer function control points (x, RGB).

Definition at line 56 of file mitkTransferFunction.h.

Constructor & Destructor Documentation

◆ TransferFunction() [1/2]

mitk::TransferFunction::TransferFunction ( )
protected

◆ ~TransferFunction()

mitk::TransferFunction::~TransferFunction ( )
overrideprotected

◆ TransferFunction() [2/2]

mitk::TransferFunction::TransferFunction ( const Self &  other)
protected

Member Function Documentation

◆ AddGradientOpacityPoint()

void mitk::TransferFunction::AddGradientOpacityPoint ( double  x,
double  value 
)

Add a single control point to the gradient opacity function.

Parameters
[in]xThe gradient magnitude position.
[in]valueThe opacity at this position (0.0 to 1.0).

◆ AddRGBPoint()

void mitk::TransferFunction::AddRGBPoint ( double  x,
double  r,
double  g,
double  b 
)

Add a single control point to the color transfer function.

Parameters
[in]xThe scalar value position.
[in]rRed component (0.0 to 1.0).
[in]gGreen component (0.0 to 1.0).
[in]bBlue component (0.0 to 1.0).

◆ AddScalarOpacityPoint()

void mitk::TransferFunction::AddScalarOpacityPoint ( double  x,
double  value 
)

Add a single control point to the scalar opacity function.

Parameters
[in]xThe scalar value position.
[in]valueThe opacity at this position (0.0 to 1.0).

◆ ClearGradientOpacityPoints()

void mitk::TransferFunction::ClearGradientOpacityPoints ( )

Remove all control points from the gradient opacity function.

◆ ClearRGBPoints()

void mitk::TransferFunction::ClearRGBPoints ( )

Remove all control points from the color transfer function.

◆ ClearScalarOpacityPoints()

void mitk::TransferFunction::ClearScalarOpacityPoints ( )

Remove all control points from the scalar opacity function.

◆ Clone()

Pointer mitk::TransferFunction::Clone ( ) const

◆ GetColorTransferFunction()

virtual vtkColorTransferFunction* mitk::TransferFunction::GetColorTransferFunction ( )
virtual

Get/Set wrapped vtk transfer function.

◆ GetGradientOpacityFunction()

virtual vtkPiecewiseFunction* mitk::TransferFunction::GetGradientOpacityFunction ( )
virtual

Get/Set wrapped vtk transfer function.

◆ GetGradientOpacityPoints()

TransferFunction::ControlPoints& mitk::TransferFunction::GetGradientOpacityPoints ( )

Get the gradient opacity control points.

Returns
Reference to the internal control point vector.

◆ GetHistogram()

virtual const HistogramGenerator::HistogramType* mitk::TransferFunction::GetHistogram ( )
virtual

Get histogram used for transfer function initialization.

◆ GetMax()

virtual int mitk::TransferFunction::GetMax ( )
virtual

Get/Set min/max of transfer function range for initialization.

◆ GetMin()

virtual int mitk::TransferFunction::GetMin ( )
virtual

Get/Set min/max of transfer function range for initialization.

◆ GetRGBPoints()

TransferFunction::RGBControlPoints& mitk::TransferFunction::GetRGBPoints ( )

Get the color transfer function control points.

Returns
Reference to the internal RGB control point vector.

◆ GetScalarOpacityFunction()

virtual vtkPiecewiseFunction* mitk::TransferFunction::GetScalarOpacityFunction ( )
virtual

Get/Set wrapped vtk transfer function.

◆ GetScalarOpacityPoints()

TransferFunction::ControlPoints& mitk::TransferFunction::GetScalarOpacityPoints ( )

Get the scalar opacity control points.

Returns
Reference to the internal control point vector.

◆ InitializeByItkHistogram()

void mitk::TransferFunction::InitializeByItkHistogram ( const itk::Statistics::Histogram< double > *  histogram)

Initialize all three transfer functions from an ITK histogram.

Parameters
[in]histogramThe histogram to use for initialization.

◆ InitializeByMitkImage()

void mitk::TransferFunction::InitializeByMitkImage ( const mitk::Image *  image)

Initialize all three transfer functions from an mitk::Image histogram.

Parameters
[in]imageThe image whose histogram drives the initialization.

◆ InitializeHistogram()

void mitk::TransferFunction::InitializeHistogram ( const mitk::Image *  image)

Compute and store the histogram and min/max range from an image.

Parameters
[in]imageThe image from which the histogram is computed.

◆ mitkClassMacroItkParent()

mitk::TransferFunction::mitkClassMacroItkParent ( TransferFunction  ,
itk::DataObject   
)

◆ mitkCloneMacro()

mitk::TransferFunction::mitkCloneMacro ( Self  )
protected

◆ New()

static Pointer mitk::TransferFunction::New ( )
static

◆ operator==()

bool mitk::TransferFunction::operator== ( Self &  other)

Compare two TransferFunction objects for equality.

Parameters
[in]otherThe TransferFunction to compare against.
Returns
True if all three transfer functions have identical control points.

◆ PrintSelf()

void mitk::TransferFunction::PrintSelf ( std::ostream &  os,
itk::Indent  indent 
) const
overrideprotected

◆ RemoveGradientOpacityPoint()

int mitk::TransferFunction::RemoveGradientOpacityPoint ( double  x)

Remove a control point from the gradient opacity function.

Parameters
[in]xThe gradient position of the control point to remove.
Returns
The index of the removed point, or -1 if not found.

◆ RemoveRGBPoint()

int mitk::TransferFunction::RemoveRGBPoint ( double  x)

Remove a control point from the color transfer function.

Parameters
[in]xThe scalar position of the control point to remove.
Returns
The index of the removed point, or -1 if not found.

◆ RemoveScalarOpacityPoint()

int mitk::TransferFunction::RemoveScalarOpacityPoint ( double  x)

Remove a control point from the scalar opacity function.

Parameters
[in]xThe scalar position of the control point to remove.
Returns
The index of the removed point, or -1 if not found.

◆ SetColorTransferFunction()

virtual void mitk::TransferFunction::SetColorTransferFunction ( vtkSmartPointer< vtkColorTransferFunction >  _arg)
virtual

◆ SetGradientOpacityPoints()

void mitk::TransferFunction::SetGradientOpacityPoints ( TransferFunction::ControlPoints  points)

Replace all gradient opacity control points.

Parameters
[in]pointsThe new set of (x, opacity) control points.

◆ SetMax()

virtual void mitk::TransferFunction::SetMax ( int  _arg)
virtual

Get/Set min/max of transfer function range for initialization.

◆ SetMin()

virtual void mitk::TransferFunction::SetMin ( int  _arg)
virtual

Get/Set min/max of transfer function range for initialization.

◆ SetRGBPoints()

void mitk::TransferFunction::SetRGBPoints ( TransferFunction::RGBControlPoints  rgbpoints)

Replace all color transfer function control points.

Parameters
[in]rgbpointsThe new set of (x, RGB) control points.

◆ SetScalarOpacityPoints()

void mitk::TransferFunction::SetScalarOpacityPoints ( TransferFunction::ControlPoints  points)

Replace all scalar opacity control points.

Parameters
[in]pointsThe new set of (x, opacity) control points.

Member Data Documentation

◆ m_ColorTransferFunction

vtkSmartPointer<vtkColorTransferFunction> mitk::TransferFunction::m_ColorTransferFunction
protected

Wrapped VTK color transfer function

Definition at line 220 of file mitkTransferFunction.h.

◆ m_GradientOpacityFunction

vtkSmartPointer<vtkPiecewiseFunction> mitk::TransferFunction::m_GradientOpacityFunction
protected

Wrapped VTK gradient opacity transfer function

Definition at line 217 of file mitkTransferFunction.h.

◆ m_Histogram

mitk::HistogramGenerator::HistogramType::ConstPointer mitk::TransferFunction::m_Histogram
protected

Specified or calculated histogram (used for initialization)

Definition at line 229 of file mitkTransferFunction.h.

◆ m_Max

int mitk::TransferFunction::m_Max
protected

Current range of transfer function (used for initialization)

Definition at line 226 of file mitkTransferFunction.h.

◆ m_Min

int mitk::TransferFunction::m_Min
protected

Current range of transfer function (used for initialization)

Definition at line 223 of file mitkTransferFunction.h.

◆ m_ScalarOpacityFunction

vtkSmartPointer<vtkPiecewiseFunction> mitk::TransferFunction::m_ScalarOpacityFunction
protected

Wrapped VTK scalar opacity transfer function

Definition at line 214 of file mitkTransferFunction.h.


The documentation for this class was generated from the following file: