![]() |
ImFusion SDK 4.3
|
#include <ImFusion/GL/TransferFunction.h>
Modern 1D transfer function for classification during rendering. More...
Modern 1D transfer function for classification during rendering.
A 1D transfer function describes a mapping from image intensities to the optical properties of color and opacity. In this implementation, the transfer function is either described by a set of tissues - each consisting of a set of key points - or a look-up-table (LUT). Keypoint mode: each key point defines an RGBA color for a given intensity. Colors are linearly interpolated between key points of the same tissue. LUT mode: the transfer function is directly defined by a texture in form of a 1D SharedImage of type float.
Both image intensities and colors are defined in normalized [0..1] space. The windowing is defined in original pixel value domain (e.g. Hounsfield units).
Public Types | |
enum class | Mode { Keypoint = 0 , LUT = 1 } |
Mode for rendering the TF from a set of keypoints or from a look-up-table. | |
Public Member Functions | |
TransferFunction (vec2 windowingRange=vec2(0.0, 1.0), int textureSize=256) | |
Default constructor. | |
TransferFunction (const TransferFunction &rhs) | |
TransferFunction & | operator= (TransferFunction rhs) |
bool | operator== (const TransferFunction &other) const |
bool | operator!= (const TransferFunction &other) const |
void | invert () |
Inverts this transfer function. | |
void | setDirty () |
Marks the textures of this transfer function as dirty. | |
const SharedImage * | standardTexture () const |
Returns the image storing the standard 1D TF. TransferFunction owns this pointer; it may be invalidated as soon as the TF changes. | |
const SharedImage * | preIntTexture () const |
Returns the image storing the pre-integrated TF. TransferFunction owns this pointer; it may be invalidated as soon as the TF changes. | |
vec2 | opaqueRange () const |
Returns the range of intensities where this transfer function is opaque. | |
void | addTissue (std::unique_ptr< TransferFunctionTissue > tissue) |
Adds the given texture to this TF. | |
void | removeTissue (int index) |
Removes the given texture from this TF. | |
void | clearTissues () |
Removes all tissues from this TF. | |
void | pushTissueToFront (int tissueIndex) |
Pushes the given tissue to the front of the list. | |
void | deriveFrom (const GlImage &img, int maxKeypoints=12) |
Derives a custom TF from a GlImage. | |
![]() | |
virtual void | configureDefaults () |
Retrieve the properties of this object, replaces values with their defaults and sets it again. | |
void | registerParameter (ParameterBase *param) |
Register the given Parameter or SubProperty, so that it will be configured during configure()/configuration(). | |
void | unregisterParameter (const ParameterBase *param) |
Remove the given Parameter or SubProperty from the list of registered parameters. | |
Configurable (const Configurable &rhs) | |
Configurable (Configurable &&rhs) noexcept | |
Configurable & | operator= (const Configurable &) |
Configurable & | operator= (Configurable &&) noexcept |
Public Attributes | |
Signal | signalChanged |
![]() | |
Signal | signalParametersChanged |
Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted. | |
Getters/Setters | |
bool | empty () const |
const std::vector< std::unique_ptr< TransferFunctionTissue > > & | tissues () const |
Returns the list of all tissues. | |
TransferFunctionTissue * | tissue (int index) |
Returns the tissue at the given index. | |
void | setLUT (std::unique_ptr< SharedImage > lut) |
Set 1D standard TF with an image as look-up-table and clear all tissues. | |
void | removeLUT () |
Remove the 1D standard TF and change mode to keypoints. | |
Mode | mode () |
Returns the mode which defines the rendering of the TF. | |
vec2 | windowingRange () const |
Convenience function to return the range of intensities of the applied windowing (original values). | |
void | setWindowingRange (const vec2 &newRange) |
Convenience function to set the range of intensities of the applied windowing to newRange (original values). | |
double | window () const |
Return the size of the windowing window. | |
void | setWindow (double value) |
Set the size of the windowing window. | |
double | level () const |
Return the center of the windowing window (level). | |
void | setLevel (double value) |
Set the center of the windowing window (level). | |
void | setWindowLevel (double window, double level) |
Convenience method for setting the windowing range based on window and level. | |
const std::string & | presetName () const |
Gets the name of the original preset when this transfer function was created (may be the preset name, name of the file). | |
void | setPresetName (const std::string &presetName) |
Sets the name of the original preset when this transfer function was created (may be the preset name, name of the file). | |
void | setTextureSize (int value) |
Sets the size of the transfer function texture. | |
Configurable interface | |
void | configure (const Properties *p) override |
Configure this object instance by de-serializing the given Properties. | |
void | configuration (Properties *p) const override |
Serialize the current object configuration into the given Properties object. | |
Additional Inherited Members | |
![]() | |
std::vector< Param > | m_params |
List of all registered Parameter and SubProperty instances. | |
|
explicit |
Default constructor.
windowingRange | Range of intensities (original value domain) of the applied windowing |
textureSize | Size of the transfer function texture (optional) |
bool empty | ( | ) | const |
Returns whether the TF is empty: -> keypoint mode: does not have any tissues. -> lut mode: standard TF is empty.
void setDirty | ( | ) |
Marks the textures of this transfer function as dirty.
The next time someone will retrieve one of the TF textures, they will be recomputed. Call this method every time, you change one of the transfer function's tissues directly.
void addTissue | ( | std::unique_ptr< TransferFunctionTissue > | tissue | ) |
Adds the given texture to this TF.
tissue | Tissue to add, TransferFunction will take ownership of the pointer. |
void removeTissue | ( | int | index | ) |
Removes the given texture from this TF.
index | Index of the tissue to remove, the corresponding pointer will be deleted. |
void pushTissueToFront | ( | int | tissueIndex | ) |
Pushes the given tissue to the front of the list.
tissueIndex | Index of the tissue to move to the front. |
|
overridevirtual |
Configure this object instance by de-serializing the given Properties.
The default implementation will do so automatically for all registered Parameter and SubProperty instances.
Reimplemented from Configurable.
|
overridevirtual |
Serialize the current object configuration into the given Properties object.
The default implementation will do so automatically for all registered Parameter and SubProperty instances.
Reimplemented from Configurable.