#include <mitkLabeledImageLookupTable.h>
Public Types | |
typedef LabeledImageLookupTable | Self |
typedef LookupTable | Superclass |
typedef itk::SmartPointer< Self > | Pointer |
typedef itk::SmartPointer < const Self > | ConstPointer |
typedef unsigned char | LabelType |
Public Member Functions | |
virtual const char * | GetClassName () const |
virtual void | SetColorForLabel (const LabelType &label, const vtkFloatingPointType &r, const vtkFloatingPointType &g, const vtkFloatingPointType &b, const vtkFloatingPointType a=1.0) |
virtual vtkFloatingPointType * | GetColorForLabel (const LabelType &label) |
mitk::LevelWindow | GetLevelWindow () |
Static Public Member Functions | |
static Pointer | New () |
Protected Member Functions | |
LabeledImageLookupTable () | |
virtual | ~LabeledImageLookupTable () |
virtual void | GenerateRandomColor (vtkFloatingPointType &r, vtkFloatingPointType &g, vtkFloatingPointType &b) |
virtual vtkFloatingPointType | GenerateRandomNumber () |
Protected Attributes | |
mitk::LevelWindow | m_LevelWindow |
A lookup table for 2D mapping of labeled images. The lookup table supports images with up to 256 unsigned labels. Negative labels are not supported. Please use the level/window settings as given by the GetLevelWindow() method to make sure, that the colors are rendered correctly. The colors are initialized with random colors as default. As background the label 0 is assumed. The color for the background is set to fully transparent as default.
Definition at line 39 of file mitkLabeledImageLookupTable.h.
typedef itk::SmartPointer<const Self> mitk::LabeledImageLookupTable::ConstPointer |
Reimplemented from mitk::LookupTable.
Definition at line 45 of file mitkLabeledImageLookupTable.h.
typedef unsigned char mitk::LabeledImageLookupTable::LabelType |
The data type for a label. Currently only images with labels in the range [0,255] are supported.
Definition at line 50 of file mitkLabeledImageLookupTable.h.
typedef itk::SmartPointer<Self> mitk::LabeledImageLookupTable::Pointer |
Reimplemented from mitk::LookupTable.
Definition at line 45 of file mitkLabeledImageLookupTable.h.
Standard mitk typedefs are generated by the mitkClassMacro
Reimplemented from mitk::LookupTable.
Definition at line 45 of file mitkLabeledImageLookupTable.h.
Reimplemented from mitk::LookupTable.
Definition at line 45 of file mitkLabeledImageLookupTable.h.
mitk::LabeledImageLookupTable::LabeledImageLookupTable | ( | ) | [protected] |
Default constructor. Protected to prevent "normal" creation
Definition at line 27 of file mitkLabeledImageLookupTable.cpp.
References GenerateRandomColor(), m_LevelWindow, mitk::LookupTable::m_LookupTable, New(), mitk::LevelWindow::SetFixed(), mitk::LevelWindow::SetRangeMinMax(), and mitk::LevelWindow::SetWindowBounds().
: m_LevelWindow(128,256) { if ( m_LookupTable == NULL ) { itkWarningMacro("LookupTable is NULL, it should have been initialized by the default constructor of mitk::LookupTable"); m_LookupTable = vtkLookupTable::New(); } m_LookupTable->SetNumberOfTableValues(256); // set the background to black and fully transparent m_LookupTable->SetTableValue( 0, 0.0, 0.0, 0.0, 0.0 ); // initialize the remaining 255 colors with random values and // an alpha value of 1.0 vtkFloatingPointType r, g, b; // // Initialize the random number generator with an arbitrary seed. // This way, the generated colors are random, but always the same... std::srand( 2 ); for ( vtkIdType index = 1 ; index < 256 ; ++index ) { GenerateRandomColor(r, g, b); m_LookupTable->SetTableValue(index, r, g, b); } // initialize the default level/window settings, // which can be accessed via GetLevelWindow(); m_LevelWindow.SetRangeMinMax(0,255); m_LevelWindow.SetWindowBounds(0,255); m_LevelWindow.SetFixed(true); }
mitk::LabeledImageLookupTable::~LabeledImageLookupTable | ( | ) | [protected, virtual] |
void mitk::LabeledImageLookupTable::GenerateRandomColor | ( | vtkFloatingPointType & | r, |
vtkFloatingPointType & | g, | ||
vtkFloatingPointType & | b | ||
) | [protected, virtual] |
Generates a random rgb color value. Values for rgb are in the range [0,1]
Definition at line 112 of file mitkLabeledImageLookupTable.cpp.
References GenerateRandomNumber().
Referenced by LabeledImageLookupTable().
{ r = GenerateRandomNumber(); g = GenerateRandomNumber(); b = GenerateRandomNumber(); }
vtkFloatingPointType mitk::LabeledImageLookupTable::GenerateRandomNumber | ( | ) | [protected, virtual] |
Generates a radnom number drawn from a uniform distribution in the range [0,1].
Definition at line 124 of file mitkLabeledImageLookupTable.cpp.
{
return ( ( ( vtkFloatingPointType ) ( std::rand( ) ) ) / ( ( vtkFloatingPointType ) ( RAND_MAX ) ) );
}
virtual const char* mitk::LabeledImageLookupTable::GetClassName | ( | ) | const [virtual] |
Reimplemented from mitk::LookupTable.
vtkFloatingPointType * mitk::LabeledImageLookupTable::GetColorForLabel | ( | const LabelType & | label ) | [virtual] |
Determines the color which will be used for coloring a given label.
label | the label for which the color should be returned |
Determines the color which will be used for coloring a given label.
label | the label for which the color should be returned |
Definition at line 97 of file mitkLabeledImageLookupTable.cpp.
{ if ( m_LookupTable == NULL ) { itkWarningMacro("LookupTable is NULL, but it should have been initialized by the constructor"); return NULL; } return m_LookupTable->GetTableValue( label ); }
mitk::LevelWindow mitk::LabeledImageLookupTable::GetLevelWindow | ( | ) | [inline] |
Provides access to level window settings, which should be used in combination with the LUTs generated by this filter (at lease for 2D visualization. If you use other level/window settings, it is not guaranteed, that scalar values are mapped to the correct colors.
Definition at line 82 of file mitkLabeledImageLookupTable.h.
{return m_LevelWindow;}
static Pointer mitk::LabeledImageLookupTable::New | ( | ) | [static] |
Make this object constructable by the New() Method.
Reimplemented from mitk::LookupTable.
Referenced by LabeledImageLookupTable().
void mitk::LabeledImageLookupTable::SetColorForLabel | ( | const LabelType & | label, |
const vtkFloatingPointType & | r, | ||
const vtkFloatingPointType & | g, | ||
const vtkFloatingPointType & | b, | ||
const vtkFloatingPointType | a = 1.0 |
||
) | [virtual] |
Sets the color for a given label
label | The pixel value used as a label in the image |
r | The red component of the rgba color value. Values sould be given in the range [0,1] |
g | The green component of the rgba color value. Values sould be given in the range [0,1] |
b | The blue component of the rgba color value. Values sould be given in the range [0,1] |
a | The alpha component of the rgba color value. Values sould be given in the range [0,1]. Default is 1. |
Definition at line 79 of file mitkLabeledImageLookupTable.cpp.
{ if ( m_LookupTable == NULL ) { itkWarningMacro("LookupTable is NULL, but it should have been initialized by the constructor"); return; } m_LookupTable->SetTableValue(label, r, g, b, a); }
Definition at line 107 of file mitkLabeledImageLookupTable.h.
Referenced by LabeledImageLookupTable().