14 #include <itkProcessObject.h> 16 #include <vtkColorTransferFunction.h> 17 #include <vtkPiecewiseFunction.h> 41 "Legacy Rainbow Color",
48 : m_LookupTable(vtkSmartPointer<vtkLookupTable>::New())
146 this->
SetType(static_cast<mitk::LookupTable::LookupTableType>(i));
172 for (
int i = 0; i < noValues; i++)
185 if (index > noValues)
187 MITK_INFO <<
"could not change opacity. index exceed size of lut ... " << std::endl;
234 bool equal = (
m_LookupTable->GetNumberOfColors() == olut->GetNumberOfColors()) &&
235 (
m_LookupTable->GetTableRange()[0] == olut->GetTableRange()[0]) &&
236 (
m_LookupTable->GetTableRange()[1] == olut->GetTableRange()[1]) &&
237 (
m_LookupTable->GetHueRange()[0] == olut->GetHueRange()[0]) &&
238 (
m_LookupTable->GetHueRange()[1] == olut->GetHueRange()[1]) &&
239 (
m_LookupTable->GetSaturationRange()[0] == olut->GetSaturationRange()[0]) &&
240 (
m_LookupTable->GetSaturationRange()[1] == olut->GetSaturationRange()[1]) &&
241 (
m_LookupTable->GetValueRange()[0] == olut->GetValueRange()[0]) &&
242 (
m_LookupTable->GetValueRange()[1] == olut->GetValueRange()[1]) &&
243 (
m_LookupTable->GetAlphaRange()[0] == olut->GetAlphaRange()[0]) &&
244 (
m_LookupTable->GetAlphaRange()[1] == olut->GetAlphaRange()[1]) &&
247 (
m_LookupTable->GetTable()->GetNumberOfTuples() == olut->GetTable()->GetNumberOfTuples());
250 for (vtkIdType i = 0; i <
m_LookupTable->GetNumberOfTableValues(); i++)
252 bool tvequal = (
m_LookupTable->GetTableValue(i)[0] == olut->GetTableValue(i)[0]) &&
253 (
m_LookupTable->GetTableValue(i)[1] == olut->GetTableValue(i)[1]) &&
254 (
m_LookupTable->GetTableValue(i)[2] == olut->GetTableValue(i)[2]) &&
255 (
m_LookupTable->GetTableValue(i)[3] == olut->GetTableValue(i)[3]);
256 if (tvequal ==
false)
264 return !(*
this == other);
269 if (
this == &LookupTable)
282 if (this->GetSource())
284 this->GetSource()->UpdateOutputInformation();
314 vtkSmartPointer<vtkColorTransferFunction> colorFunction = vtkSmartPointer<vtkColorTransferFunction>::New();
319 auto cols =
new double[3 * num_of_values];
320 double *colsHead = cols;
322 for (
int i = 0; i < num_of_values; ++i)
324 *cols =
static_cast<double>(*rawLookupTable) / 255.0;
327 *cols =
static_cast<double>(*rawLookupTable) / 255.0;
330 *cols =
static_cast<double>(*rawLookupTable) / 255.0;
335 colorFunction->BuildFunctionFromTable(
337 return colorFunction;
347 vtkSmartPointer<vtkPiecewiseFunction> opacityFunction = vtkSmartPointer<vtkPiecewiseFunction>::New();
352 auto alphas =
new double[num_of_values];
353 double *alphasHead = alphas;
356 for (
int i = 0; i < num_of_values; ++i)
358 *alphas =
static_cast<double>(*rgba) / 255.0;
363 opacityFunction->BuildFunctionFromTable(
365 return opacityFunction;
375 vtkSmartPointer<vtkPiecewiseFunction> gradientFunction = vtkSmartPointer<vtkPiecewiseFunction>::New();
380 auto alphas =
new double[num_of_values];
381 double *alphasHead = alphas;
384 for (
int i = 0; i < num_of_values; ++i)
386 *alphas =
static_cast<double>(*rgba) / 255.0;
391 gradientFunction->BuildFunctionFromTable(
393 return gradientFunction;
407 itk::LightObject::Pointer mitk::LookupTable::InternalClone()
const 409 itk::LightObject::Pointer result(
new Self(*
this));
410 result->UnRegister();
416 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New();
417 lut->SetRampToLinear();
418 lut->SetSaturationRange(0.0, 0.0);
419 lut->SetHueRange(0.0, 0.0);
420 lut->SetValueRange(0.0, 1.0);
429 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New();
430 lut->SetRampToLinear();
431 lut->SetSaturationRange(0.0, 0.0);
432 lut->SetHueRange(0.0, 0.0);
433 lut->SetValueRange(0.0, 1.0);
435 lut->SetTableValue(0, 0.0, 0.0, 0.0, 0.0);
443 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New();
444 lut->SetTableRange(0, 1);
445 lut->SetSaturationRange(0, 0);
446 lut->SetHueRange(0, 0);
447 lut->SetValueRange(1, 0);
448 lut->SetAlphaRange(1, 0);
457 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New();
458 lut->SetNumberOfTableValues(256);
461 for (
int i = 0; i < 256; i++)
464 i, (
double)
HotIron[i][0] / 255.0, (
double)
HotIron[i][1] / 255.0, (
double)
HotIron[i][2] / 255.0, 1.0);
473 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New();
474 lut->SetNumberOfTableValues(256);
481 lut->SetTableValue(0, (
double)
Jet[0][0] / 255.0, (
double)
Jet[0][1] / 255.0, (
double)
Jet[0][2] / 255.0, 0.0);
487 lut->SetTableValue(i, (
double)
Jet[i][0] / 255.0, (
double)
Jet[i][1] / 255.0, (
double)
Jet[i][2] / 255.0, 1.0);
496 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New();
497 lut->SetNumberOfTableValues(256);
501 for (
int i = 0; i < 256; i++)
513 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New();
514 lut->SetNumberOfTableValues(256);
518 for (
int i = 0; i < 256; i++)
520 lut->SetTableValue(i, (
double)
PET20[i][0] / 255.0, (
double)
PET20[i][1] / 255.0, (
double)
PET20[i][2] / 255.0, 1.0);
529 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New();
530 lut->SetNumberOfTableValues(65536);
531 lut->SetTableRange(0, 65536);
534 lut->SetTableValue(0, 0.0, 0.0, 0.0, 0.0);
536 for (
int i = 0; i < 25; i++)
541 for (
int i = 26; i < 65536; i++)
544 lut->SetTableValue(i, 1.0, 0.0, 0.0, 0.4);
545 else if (i % 12 == 1)
546 lut->SetTableValue(i, 0.0, 1.0, 0.0, 0.4);
547 else if (i % 12 == 2)
548 lut->SetTableValue(i, 0.0, 0.0, 1.0, 0.4);
549 else if (i % 12 == 3)
550 lut->SetTableValue(i, 1.0, 1.0, 0.0, 0.4);
551 else if (i % 12 == 4)
552 lut->SetTableValue(i, 0.0, 1.0, 1.0, 0.4);
553 else if (i % 12 == 5)
554 lut->SetTableValue(i, 1.0, 0.0, 1.0, 0.4);
555 else if (i % 12 == 6)
556 lut->SetTableValue(i, 1.0, 0.5, 0.0, 0.4);
557 else if (i % 12 == 7)
558 lut->SetTableValue(i, 0.0, 1.0, 0.5, 0.4);
559 else if (i % 12 == 8)
560 lut->SetTableValue(i, 0.5, 0.0, 1.0, 0.4);
561 else if (i % 12 == 9)
562 lut->SetTableValue(i, 1.0, 1.0, 0.5, 0.4);
563 else if (i % 12 == 10)
564 lut->SetTableValue(i, 0.5, 1.0, 1.0, 0.4);
565 else if (i % 12 == 11)
566 lut->SetTableValue(i, 1.0, 0.5, 1.0, 0.4);
575 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New();
576 lut->SetRampToLinear();
577 lut->SetHueRange(0.6667, 0.0);
578 lut->SetTableRange(0.0, 20.0);
587 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New();
588 lut->SetNumberOfTableValues(256);
591 for (
int i = 0; i < 256; i++)
594 i, (
double)
Plasma[i][0] / 255.0, (
double)
Plasma[i][1] / 255.0, (
double)
Plasma[i][2] / 255.0, 1.0);
603 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New();
604 lut->SetNumberOfTableValues(256);
607 for (
int i = 0; i < 256; i++)
610 i, (
double)
Inferno[i][0] / 255.0, (
double)
Inferno[i][1] / 255.0, (
double)
Inferno[i][2] / 255.0, 1.0);
619 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New();
620 lut->SetNumberOfTableValues(256);
623 for (
int i = 0; i < 256; i++)
626 i, (
double)
Viridis[i][0] / 255.0, (
double)
Viridis[i][1] / 255.0, (
double)
Viridis[i][2] / 255.0, 1.0);
635 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New();
636 lut->SetNumberOfTableValues(256);
639 for (
int i = 0; i < 256; i++)
642 i, (
double)
Magma[i][0] / 255.0, (
double)
Magma[i][1] / 255.0, (
double)
Magma[i][2] / 255.0, 1.0);
virtual void SetTableValue(int index, double rgba[4])
SetTableValue convenience method wrapping the vtkLookupTable::SetTableValue() method.
virtual bool operator!=(const LookupTable &LookupTable) const
non equality operator implementation
virtual void BuildGrayScaleLookupTable()
bool VerifyRequestedRegion() override
Checks if the requested region is completely contained in the buffered region. Since we always want t...
static const int Plasma[256][3]
virtual void BuildInverseGrayScaleLookupTable()
virtual vtkSmartPointer< vtkLookupTable > GetVtkLookupTable() const
GetVtkLookupTable Getter for the internally wrapped vtkLookupTable.
LookupTableType
The LookupTableType enum for different predefined lookup tables.
virtual void BuildPlasmaLookupTable()
static std::vector< std::string > typenameList
virtual void BuildPETColorLookupTable()
DataCollection - Class to facilitate loading/accessing structured data.
virtual void BuildMagmaLookupTable()
virtual void ChangeOpacityForAll(float opacity)
ChangeOpacityForAll Set the opacity for all table values.
void SetRequestedRegionToLargestPossibleRegion() override
Sets the requested Region to the largest possible region. This method is not implemented, since this is the default behavior of the itk pipeline and we do not support the requested-region mechanism for lookup-tables.
virtual void GetTableValue(int index, double rgba[4])
GetTableValue convenience method wrapping the vtkLookupTable::GetTableValue() method.
virtual LookupTableType GetActiveType() const
Return the current look-up table type.
static const int HotIron[256][3]
static const int Inferno[256][3]
void SetRequestedRegion(const itk::DataObject *data) override
This method has no effect for lookup tables, since we do not support the region-mechanism.
void UpdateOutputInformation() override
Updates the output information of the current object by calling updateOutputInformation of the data o...
vtkSmartPointer< vtkPiecewiseFunction > CreateGradientTransferFunction()
virtual bool operator==(const mitk::LookupTable &LookupTable) const
equality operator implementation
static const int Viridis[256][3]
virtual void BuildLegacyRainbowColorLookupTable()
virtual void BuildJetLookupTable(bool transparent=false)
virtual LookupTable & operator=(const LookupTable &LookupTable)
implementation necessary because operator made private in itk::Object
static const int Jet[256][3]
virtual void BuildViridisLookupTable()
static const int Magma[256][3]
vtkSmartPointer< vtkPiecewiseFunction > CreateOpacityTransferFunction()
static const double Multilabel[25][3]
virtual void BuildInfernoLookupTable()
virtual void BuildPET20LookupTable()
vtkSmartPointer< vtkLookupTable > m_LookupTable
virtual void BuildHotIronLookupTable()
virtual std::string GetActiveTypeAsString() const
Return the current look-up table type as a string.
void PrintSelf(std::ostream &os, itk::Indent indent) const override
unsigned char RawLookupTableType
RawLookupTableType raw lookuptable typedef for convenience.
vtkSmartPointer< vtkColorTransferFunction > CreateColorTransferFunction()
virtual void ChangeOpacity(int index, float opacity)
ChangeOpacity Set the opacity for a specific table index.
virtual void GetColor(double value, double rgb[3])
GetColor convenience method wrapping the vtkLookupTable::GetColor() method.
virtual void BuildLegacyBinaryLookupTable()
virtual void SetVtkLookupTable(vtkSmartPointer< vtkLookupTable > lut)
SetVtkLookupTable Setter for the internal lookuptable.
virtual RawLookupTableType * GetRawLookupTable() const
GetRawLookupTable Getter for the raw lookuptable array.
static const int PET20[256][3]
bool RequestedRegionIsOutsideOfTheBufferedRegion() override
Checks, if the requested region lies outside of the buffered region by calling verifyRequestedRegion(...
virtual void SetType(const LookupTableType type)
Set the look-up table type by enum (or integer).
virtual void BuildMultiLabelLookupTable()
The LookupTable class mitk wrapper for a vtkLookupTableThis class can be used to color images with a ...
static const int PETColor[256][3]