18 #include <itkProcessObject.h>
20 #include <vtkColorTransferFunction.h>
21 #include <vtkPiecewiseFunction.h>
36 "Legacy Rainbow Color",
50 :
itk::DataObject(), m_LookupTable(vtkSmartPointer<vtkLookupTable>::
New())
61 if ((!lut) || (m_LookupTable == lut))
78 this->BuildGrayScaleLookupTable();
81 this->BuildInverseGrayScaleLookupTable();
84 this->BuildHotIronLookupTable();
87 this->BuildJetLookupTable();
90 this->BuildJetLookupTable(
true);
93 this->BuildLegacyBinaryLookupTable();
96 this->BuildMultiLabelLookupTable();
99 this->BuildPETColorLookupTable();
102 this->BuildPET20LookupTable();
105 this->BuildLegacyRainbowColorLookupTable();
118 std::string lutType = this->typenameList[i];
120 while (lutType !=
"END_OF_ARRAY")
122 if (lutType == typeName)
124 this->SetType(static_cast<mitk::LookupTable::LookupTableType>(i));
127 lutType = this->typenameList[++i];
133 return std::string(typenameList[(
int)m_type]);
138 int noValues = m_LookupTable->GetNumberOfTableValues();
142 for (
int i = 0; i < noValues; i++)
144 m_LookupTable->GetTableValue(i, rgba);
146 m_LookupTable->SetTableValue(i, rgba);
154 int noValues = m_LookupTable->GetNumberOfTableValues();
155 if (index > noValues)
157 MITK_INFO <<
"could not change opacity. index exceed size of lut ... " << std::endl;
163 m_LookupTable->GetTableValue(index, rgba);
165 m_LookupTable->SetTableValue(index, rgba);
173 this->GetVtkLookupTable()->GetColor(value, rgb);
178 this->GetVtkLookupTable()->GetTableValue(index, rgba);
183 this->GetVtkLookupTable()->SetTableValue(index, rgba);
188 return m_LookupTable;
193 return m_LookupTable->GetPointer(0);
207 bool equal = (m_LookupTable->GetNumberOfColors() == olut->GetNumberOfColors()) &&
208 (m_LookupTable->GetTableRange()[0] == olut->GetTableRange()[0]) &&
209 (m_LookupTable->GetTableRange()[1] == olut->GetTableRange()[1]) &&
210 (m_LookupTable->GetHueRange()[0] == olut->GetHueRange()[0]) &&
211 (m_LookupTable->GetHueRange()[1] == olut->GetHueRange()[1]) &&
212 (m_LookupTable->GetSaturationRange()[0] == olut->GetSaturationRange()[0]) &&
213 (m_LookupTable->GetSaturationRange()[1] == olut->GetSaturationRange()[1]) &&
214 (m_LookupTable->GetValueRange()[0] == olut->GetValueRange()[0]) &&
215 (m_LookupTable->GetValueRange()[1] == olut->GetValueRange()[1]) &&
216 (m_LookupTable->GetAlphaRange()[0] == olut->GetAlphaRange()[0]) &&
217 (m_LookupTable->GetAlphaRange()[1] == olut->GetAlphaRange()[1]) &&
218 (m_LookupTable->GetRamp() == olut->GetRamp()) && (m_LookupTable->GetScale() == olut->GetScale()) &&
219 (m_LookupTable->GetAlpha() == olut->GetAlpha()) &&
220 (m_LookupTable->GetTable()->GetNumberOfTuples() == olut->GetTable()->GetNumberOfTuples());
223 for (vtkIdType i = 0; i < m_LookupTable->GetNumberOfTableValues(); i++)
225 bool tvequal = (m_LookupTable->GetTableValue(i)[0] == olut->GetTableValue(i)[0]) &&
226 (m_LookupTable->GetTableValue(i)[1] == olut->GetTableValue(i)[1]) &&
227 (m_LookupTable->GetTableValue(i)[2] == olut->GetTableValue(i)[2]) &&
228 (m_LookupTable->GetTableValue(i)[3] == olut->GetTableValue(i)[3]);
229 if (tvequal ==
false)
240 return !(*
this == other);
248 if (
this == &LookupTable)
261 if (this->GetSource())
263 this->GetSource()->UpdateOutputInformation();
296 int num_of_values = m_LookupTable->GetNumberOfTableValues();
298 auto cols =
new double[3 * num_of_values];
299 double *colsHead = cols;
301 for (
int i = 0; i < num_of_values; ++i)
303 *cols =
static_cast<double>(*rawLookupTable) / 255.0;
306 *cols =
static_cast<double>(*rawLookupTable) / 255.0;
309 *cols =
static_cast<double>(*rawLookupTable) / 255.0;
314 colorFunction->BuildFunctionFromTable(
315 m_LookupTable->GetTableRange()[0], m_LookupTable->GetTableRange()[1], num_of_values, colsHead);
316 return colorFunction;
321 colorFunction = this->CreateColorTransferFunction();
329 int num_of_values = m_LookupTable->GetNumberOfTableValues();
331 auto alphas =
new double[num_of_values];
332 double *alphasHead = alphas;
335 for (
int i = 0; i < num_of_values; ++i)
337 *alphas =
static_cast<double>(*rgba) / 255.0;
342 opacityFunction->BuildFunctionFromTable(
343 m_LookupTable->GetTableRange()[0], m_LookupTable->GetTableRange()[1], num_of_values, alphasHead);
344 return opacityFunction;
349 opacityFunction = this->CreateOpacityTransferFunction();
357 int num_of_values = m_LookupTable->GetNumberOfTableValues();
359 auto alphas =
new double[num_of_values];
360 double *alphasHead = alphas;
363 for (
int i = 0; i < num_of_values; ++i)
365 *alphas =
static_cast<double>(*rgba) / 255.0;
370 gradientFunction->BuildFunctionFromTable(
371 m_LookupTable->GetTableRange()[0], m_LookupTable->GetTableRange()[1], num_of_values, alphasHead);
372 return gradientFunction;
377 gradientFunction = this->CreateGradientTransferFunction();
383 m_LookupTable->PrintHeader(os, vtkIndent());
389 result->UnRegister();
396 lut->SetRampToLinear();
397 lut->SetSaturationRange(0.0, 0.0);
398 lut->SetHueRange(0.0, 0.0);
399 lut->SetValueRange(0.0, 1.0);
409 lut->SetRampToLinear();
410 lut->SetSaturationRange(0.0, 0.0);
411 lut->SetHueRange(0.0, 0.0);
412 lut->SetValueRange(0.0, 1.0);
414 lut->SetTableValue(0, 0.0, 0.0, 0.0, 0.0);
423 lut->SetTableRange(0, 1);
424 lut->SetSaturationRange(0, 0);
425 lut->SetHueRange(0, 0);
426 lut->SetValueRange(1, 0);
427 lut->SetAlphaRange(1, 0);
437 lut->SetNumberOfTableValues(256);
440 for (
int i = 0; i < 256; i++)
443 i, (
double)
HotIron[i][0] / 255.0, (
double)
HotIron[i][1] / 255.0, (
double)
HotIron[i][2] / 255.0, 1.0);
453 lut->SetNumberOfTableValues(256);
460 lut->SetTableValue(0, (
double)
Jet[0][0] / 255.0, (
double)
Jet[0][1] / 255.0, (
double)
Jet[0][2] / 255.0, 0.0);
466 lut->SetTableValue(i, (
double)
Jet[i][0] / 255.0, (
double)
Jet[i][1] / 255.0, (
double)
Jet[i][2] / 255.0, 1.0);
476 lut->SetNumberOfTableValues(256);
477 lut->SetTableRange((m_Level - m_Window / 2.0), (m_Level + m_Window / 2.0));
480 for (
int i = 0; i < 256; i++)
493 lut->SetNumberOfTableValues(256);
494 lut->SetTableRange((m_Level - m_Window / 2.0), (m_Level + m_Window / 2.0));
497 for (
int i = 0; i < 256; i++)
499 lut->SetTableValue(i, (
double)
PET20[i][0] / 255.0, (
double)
PET20[i][1] / 255.0, (
double)
PET20[i][2] / 255.0, 1.0);
509 lut->SetNumberOfTableValues(65536);
510 lut->SetTableRange(0, 65536);
511 lut->SetTableValue(0, 0.0, 0.0, 0.0, 0.0);
513 lut->SetTableValue(1, 1.0, 1.0, 0.0, 0.4);
514 lut->SetTableValue(2, 0.0, 1.0, 0.0, 0.4);
515 lut->SetTableValue(3, 0.0, 0.0, 1.0, 0.4);
516 lut->SetTableValue(4, 1.0, 1.0, 0.4, 0.4);
517 lut->SetTableValue(5, 0.0, 0.4, 0.7, 0.4);
518 lut->SetTableValue(6, 1.0, 0.0, 1.0, 0.4);
520 lut->SetTableValue(7, 1.0, 0.5, 0.0, 0.4);
521 lut->SetTableValue(8, 0.0, 1.0, 0.5, 0.4);
522 lut->SetTableValue(9, 0.5, 0.0, 1.0, 0.4);
523 lut->SetTableValue(10, 1.0, 1.0, 0.5, 0.4);
524 lut->SetTableValue(11, 0.5, 1.0, 1.0, 0.4);
525 lut->SetTableValue(12, 1.0, 0.5, 0.6, 0.4);
526 lut->SetTableValue(13, 1.0, 0.3, 0.3, 0.4);
527 lut->SetTableValue(14, 0.4, 0.7, 1.0, 0.4);
528 lut->SetTableValue(15, 0.4, 0.5, 1.0, 0.4);
529 lut->SetTableValue(16, 0.8, 0.5, 1.0, 0.4);
530 lut->SetTableValue(17, 1.0, 0.3, 1.0, 0.4);
531 lut->SetTableValue(18, 1.0, 0.5, 0.6, 0.4);
532 lut->SetTableValue(19, 1.0, 0.5, 0.4, 0.4);
533 lut->SetTableValue(20, 0.4, 0.5, 0.4, 0.4);
534 lut->SetTableValue(21, 1.0, 0.5, 0.76, 0.4);
535 lut->SetTableValue(22, 0.76, 0.4, 0.4, 0.4);
536 lut->SetTableValue(23, 1.0, 0.5, 0.4, 0.4);
537 lut->SetTableValue(24, 0.76, 0.3, 0.4, 0.4);
538 lut->SetTableValue(25, 1.0, 0.3, 0.4, 0.4);
540 for (
int i = 26; i < 65536; i++)
543 lut->SetTableValue(i, 1.0, 0.0, 0.0, 0.4);
544 else if (i % 12 == 1)
545 lut->SetTableValue(i, 0.0, 1.0, 0.0, 0.4);
546 else if (i % 12 == 2)
547 lut->SetTableValue(i, 0.0, 0.0, 1.0, 0.4);
548 else if (i % 12 == 3)
549 lut->SetTableValue(i, 1.0, 1.0, 0.0, 0.4);
550 else if (i % 12 == 4)
551 lut->SetTableValue(i, 0.0, 1.0, 1.0, 0.4);
552 else if (i % 12 == 5)
553 lut->SetTableValue(i, 1.0, 0.0, 1.0, 0.4);
554 else if (i % 12 == 6)
555 lut->SetTableValue(i, 1.0, 0.5, 0.0, 0.4);
556 else if (i % 12 == 7)
557 lut->SetTableValue(i, 0.0, 1.0, 0.5, 0.4);
558 else if (i % 12 == 8)
559 lut->SetTableValue(i, 0.5, 0.0, 1.0, 0.4);
560 else if (i % 12 == 9)
561 lut->SetTableValue(i, 1.0, 1.0, 0.5, 0.4);
562 else if (i % 12 == 10)
563 lut->SetTableValue(i, 0.5, 1.0, 1.0, 0.4);
564 else if (i % 12 == 11)
565 lut->SetTableValue(i, 1.0, 0.5, 1.0, 0.4);
575 lut->SetRampToLinear();
576 lut->SetHueRange(0.6667, 0.0);
577 lut->SetTableRange(0.0, 20.0);
virtual void SetTableValue(int index, double rgba[4])
SetTableValue convenience method wrapping the vtkLookupTable::SetTableValue() method.
virtual vtkSmartPointer< vtkLookupTable > GetVtkLookupTable() const
GetVtkLookupTable Getter for the internally wrapped vtkLookupTable.
virtual void BuildGrayScaleLookupTable()
virtual bool VerifyRequestedRegion() override
itk::SmartPointer< Self > Pointer
virtual void BuildInverseGrayScaleLookupTable()
LookupTableType
The LookupTableType enum for different predefined lookup tables.
virtual void BuildPETColorLookupTable()
virtual RawLookupTableType * GetRawLookupTable() const
GetRawLookupTable Getter for the raw lookuptable array.
DataCollection - Class to facilitate loading/accessing structured data.
static const char *const typenameList[]
virtual void ChangeOpacityForAll(float opacity)
ChangeOpacityForAll Set the opacity for all table values.
virtual void SetRequestedRegionToLargestPossibleRegion() override
virtual void GetTableValue(int index, double rgba[4])
GetTableValue convenience method wrapping the vtkLookupTable::GetTableValue() method.
static const int HotIron[256][3]
virtual bool operator==(const mitk::LookupTable &LookupTable) const
equality operator implementation
virtual void SetRequestedRegion(const itk::DataObject *data) override
virtual void UpdateOutputInformation() override
vtkSmartPointer< vtkPiecewiseFunction > CreateGradientTransferFunction()
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]
vtkSmartPointer< vtkPiecewiseFunction > CreateOpacityTransferFunction()
virtual bool operator!=(const LookupTable &LookupTable) const
non equality operator implementation
virtual void BuildPET20LookupTable()
vtkSmartPointer< vtkLookupTable > m_LookupTable
virtual void BuildHotIronLookupTable()
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.
static const int PET20[256][3]
virtual bool RequestedRegionIsOutsideOfTheBufferedRegion() override
virtual const std::string GetActiveTypeAsString()
Return the current look-up table type as a string.
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]
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.