diff --git a/Modules/Core/include/Colortables/Plasma.h b/Modules/Core/include/Colortables/Plasma.h new file mode 100644 index 0000000000..843e5b88f2 --- /dev/null +++ b/Modules/Core/include/Colortables/Plasma.h @@ -0,0 +1,59 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#ifndef _lut_Plasma_h_ +#define _lut_Plasma_h_ + +static const int Plasma[256][3] = +{ { 13, 8, 135 },{ 16, 7, 136 },{ 19, 7, 137 },{ 22, 7, 138 },{ 25, 6, 140 },{ 27, 6, 141 },{ 29, 6, 142 },{ 32, 6, 143 }, + { 34, 6, 144 },{ 36, 6, 145 },{ 38, 5, 145 },{ 40, 5, 146 },{ 42, 5, 147 },{ 44, 5, 148 },{ 46, 5, 149 },{ 47, 5, 150 }, + { 49, 5, 151 },{ 51, 5, 151 },{ 53, 4, 152 },{ 55, 4, 153 },{ 56, 4, 154 },{ 58, 4, 154 },{ 60, 4, 155 },{ 62, 4, 156 }, + { 63, 4, 156 },{ 65, 4, 157 },{ 67, 3, 158 },{ 68, 3, 158 },{ 70, 3, 159 },{ 72, 3, 159 },{ 73, 3, 160 },{ 75, 3, 161 }, + { 76, 2, 161 },{ 78, 2, 162 },{ 80, 2, 162 },{ 81, 2, 163 },{ 83, 2, 163 },{ 85, 2, 164 },{ 86, 1, 164 },{ 88, 1, 164 }, + { 89, 1, 165 },{ 91, 1, 165 },{ 92, 1, 166 },{ 94, 1, 166 },{ 96, 1, 166 },{ 97, 0, 167 },{ 99, 0, 167 },{ 100, 0, 167 }, + { 102, 0, 167 },{ 103, 0, 168 },{ 105, 0, 168 },{ 106, 0, 168 },{ 108, 0, 168 },{ 110, 0, 168 },{ 111, 0, 168 },{ 113, 0, 168 }, + { 114, 1, 168 },{ 116, 1, 168 },{ 117, 1, 168 },{ 119, 1, 168 },{ 120, 1, 168 },{ 122, 2, 168 },{ 123, 2, 168 },{ 125, 3, 168 }, + { 126, 3, 168 },{ 128, 4, 168 },{ 129, 4, 167 },{ 131, 5, 167 },{ 132, 5, 167 },{ 134, 6, 166 },{ 135, 7, 166 },{ 136, 8, 166 }, + { 138, 9, 165 },{ 139, 10, 165 },{ 141, 11, 165 },{ 142, 12, 164 },{ 143, 13, 164 },{ 145, 14, 163 },{ 146, 15, 163 },{ 148, 16, 162 }, + { 149, 17, 161 },{ 150, 19, 161 },{ 152, 20, 160 },{ 153, 21, 159 },{ 154, 22, 159 },{ 156, 23, 158 },{ 157, 24, 157 }, + { 158, 25, 157 },{ 160, 26, 156 },{ 161, 27, 155 },{ 162, 29, 154 },{ 163, 30, 154 },{ 165, 31, 153 },{ 166, 32, 152 }, + { 167, 33, 151 },{ 168, 34, 150 },{ 170, 35, 149 },{ 171, 36, 148 },{ 172, 38, 148 },{ 173, 39, 147 },{ 174, 40, 146 }, + { 176, 41, 145 },{ 177, 42, 144 },{ 178, 43, 143 },{ 179, 44, 142 },{ 180, 46, 141 },{ 181, 47, 140 },{ 182, 48, 139 }, + { 183, 49, 138 },{ 184, 50, 137 },{ 186, 51, 136 },{ 187, 52, 136 },{ 188, 53, 135 },{ 189, 55, 134 },{ 190, 56, 133 }, + { 191, 57, 132 },{ 192, 58, 131 },{ 193, 59, 130 },{ 194, 60, 129 },{ 195, 61, 128 },{ 196, 62, 127 },{ 197, 64, 126 }, + { 198, 65, 125 },{ 199, 66, 124 },{ 200, 67, 123 },{ 201, 68, 122 },{ 202, 69, 122 },{ 203, 70, 121 },{ 204, 71, 120 }, + { 204, 73, 119 },{ 205, 74, 118 },{ 206, 75, 117 },{ 207, 76, 116 },{ 208, 77, 115 },{ 209, 78, 114 },{ 210, 79, 113 }, + { 211, 81, 113 },{ 212, 82, 112 },{ 213, 83, 111 },{ 213, 84, 110 },{ 214, 85, 109 },{ 215, 86, 108 },{ 216, 87, 107 }, + { 217, 88, 106 },{ 218, 90, 106 },{ 218, 91, 105 },{ 219, 92, 104 },{ 220, 93, 103 },{ 221, 94, 102 },{ 222, 95, 101 }, + { 222, 97, 100 },{ 223, 98, 99 },{ 224, 99, 99 },{ 225, 100, 98 },{ 226, 101, 97 },{ 226, 102, 96 },{ 227, 104, 95 }, + { 228, 105, 94 },{ 229, 106, 93 },{ 229, 107, 93 },{ 230, 108, 92 },{ 231, 110, 91 },{ 231, 111, 90 },{ 232, 112, 89 }, + { 233, 113, 88 },{ 233, 114, 87 },{ 234, 116, 87 },{ 235, 117, 86 },{ 235, 118, 85 },{ 236, 119, 84 },{ 237, 121, 83 }, + { 237, 122, 82 },{ 238, 123, 81 },{ 239, 124, 81 },{ 239, 126, 80 },{ 240, 127, 79 },{ 240, 128, 78 },{ 241, 129, 77 }, + { 241, 131, 76 },{ 242, 132, 75 },{ 243, 133, 75 },{ 243, 135, 74 },{ 244, 136, 73 },{ 244, 137, 72 },{ 245, 139, 71 }, + { 245, 140, 70 },{ 246, 141, 69 },{ 246, 143, 68 },{ 247, 144, 68 },{ 247, 145, 67 },{ 247, 147, 66 },{ 248, 148, 65 }, + { 248, 149, 64 },{ 249, 151, 63 },{ 249, 152, 62 },{ 249, 154, 62 },{ 250, 155, 61 },{ 250, 156, 60 },{ 250, 158, 59 }, + { 251, 159, 58 },{ 251, 161, 57 },{ 251, 162, 56 },{ 252, 163, 56 },{ 252, 165, 55 },{ 252, 166, 54 },{ 252, 168, 53 }, + { 252, 169, 52 },{ 253, 171, 51 },{ 253, 172, 51 },{ 253, 174, 50 },{ 253, 175, 49 },{ 253, 177, 48 },{ 253, 178, 47 }, + { 253, 180, 47 },{ 253, 181, 46 },{ 254, 183, 45 },{ 254, 184, 44 },{ 254, 186, 44 },{ 254, 187, 43 },{ 254, 189, 42 }, + { 254, 190, 42 },{ 254, 192, 41 },{ 253, 194, 41 },{ 253, 195, 40 },{ 253, 197, 39 },{ 253, 198, 39 },{ 253, 200, 39 }, + { 253, 202, 38 },{ 253, 203, 38 },{ 252, 205, 37 },{ 252, 206, 37 },{ 252, 208, 37 },{ 252, 210, 37 },{ 251, 211, 36 }, + { 251, 213, 36 },{ 251, 215, 36 },{ 250, 216, 36 },{ 250, 218, 36 },{ 249, 220, 36 },{ 249, 221, 37 },{ 248, 223, 37 }, + { 248, 225, 37 },{ 247, 226, 37 },{ 247, 228, 37 },{ 246, 230, 38 },{ 246, 232, 38 },{ 245, 233, 38 },{ 245, 235, 39 }, + { 244, 237, 39 },{ 243, 238, 39 },{ 243, 240, 39 },{ 242, 242, 39 },{ 241, 244, 38 },{ 241, 245, 37 },{ 240, 247, 36 },{ 240, 249, 33 } +}; +#endif + + diff --git a/Modules/Core/include/mitkLookupTable.h b/Modules/Core/include/mitkLookupTable.h index 0f3b8b530b..d658bddb10 100644 --- a/Modules/Core/include/mitkLookupTable.h +++ b/Modules/Core/include/mitkLookupTable.h @@ -1,267 +1,267 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef mitkLookupTable_h #define mitkLookupTable_h #include "mitkCommon.h" #include #include #include #include #include class vtkColorTransferFunction; class vtkPiecewiseFunction; namespace mitk { /** * @brief The LookupTable class mitk wrapper for a vtkLookupTable * @ingroup DataManagement * * This class can be used to color images with a LookupTable, such as the * vtkLookupTable. * @note If you want to use this as a property for an mitk::Image, make sure * to use the mitk::LookupTableProperty and set the mitk::RenderingModeProperty * to a mode which supports lookup tables (e.g. LOOKUPTABLE_COLOR). Make * sure to check the documentation of the mitk::RenderingModeProperty. For a * code example how to use the mitk::LookupTable check the * mitkImageVtkMapper2DLookupTableTest.cpp in Core\Code\Testing. */ class MITKCORE_EXPORT LookupTable : public itk::DataObject { public: /** * @brief RawLookupTableType raw lookuptable typedef for convenience. */ typedef unsigned char RawLookupTableType; mitkClassMacroItkParent(LookupTable, itk::DataObject); itkFactorylessNewMacro(Self) itkCloneMacro(Self) /** * @brief GetVtkLookupTable Getter for the internally wrapped vtkLookupTable. */ virtual vtkSmartPointer GetVtkLookupTable() const; /** * @brief GetRawLookupTable Getter for the raw lookuptable array. */ virtual RawLookupTableType *GetRawLookupTable() const; /** * @brief SetVtkLookupTable Setter for the internal lookuptable. * @param lut The lookuptable. */ virtual void SetVtkLookupTable(vtkSmartPointer lut); /** * @brief ChangeOpacityForAll Set the opacity for all table values. * @param opacity Opacity between 0.0 and 1.0. */ virtual void ChangeOpacityForAll(float opacity); /** * @brief ChangeOpacity Set the opacity for a specific table index. * @param index The lookuptable index. * @param opacity Opacity between 0.0 and 1.0. */ virtual void ChangeOpacity(int index, float opacity); /** * @brief GetColor convenience method wrapping the vtkLookupTable::GetColor() method. * * Map one value through the lookup table and return the color as an RGB array of doubles between 0 and 1. * @param value The value you want to map. * @param rgb RGB values between 0 and 1. */ virtual void GetColor(double value, double rgb[3]); /** * @brief GetTableValue convenience method wrapping the vtkLookupTable::GetTableValue() method. * @param index The index you want to get. * @param rgba RGB values between 0 and 1. */ virtual void GetTableValue(int index, double rgba[4]); /** * @brief SetTableValue convenience method wrapping the vtkLookupTable::SetTableValue() method. * @param index The index you want to set. * @param rgba RGB values between 0 and 1. */ virtual void SetTableValue(int index, double rgba[4]); itkSetMacro(Window, float); itkSetMacro(Level, float); itkSetMacro(Opacity, float); /*! * \brief equality operator implementation */ virtual bool operator==(const mitk::LookupTable &LookupTable) const; /*! * \brief non equality operator implementation */ virtual bool operator!=(const LookupTable &LookupTable) const; /*! * \brief implementation necessary because operator made * private in itk::Object */ virtual LookupTable &operator=(const LookupTable &LookupTable); /** * Updates the output information of the current object by calling * updateOutputInformation of the data objects source object. */ void UpdateOutputInformation() override; /** * Sets the requested Region to the largest possible region. * This method is not implemented, since this is the default * behaviour of the itk pipeline and we do not support the * requested-region mechanism for lookup-tables */ void SetRequestedRegionToLargestPossibleRegion() override; /** * Checks, if the requested region lies outside of the buffered region by * calling verifyRequestedRegion(). */ bool RequestedRegionIsOutsideOfTheBufferedRegion() override; /** * Checks if the requested region is completely contained in * the buffered region. Since we always want to process the lookup * table as a whole, this method always returns true */ bool VerifyRequestedRegion() override; /** * This method has no effect for lookup tables, since we do * not support the region-mechanism */ void SetRequestedRegion(const itk::DataObject *data) override; LookupTable(); ~LookupTable() override; /** * \deprecatedSince{2014_03} Please use CreateColorTransferFunction() instead */ DEPRECATED(void CreateColorTransferFunction(vtkColorTransferFunction *&colorFunction)); /** * \deprecatedSince{2014_03} Please use CreateOpacityTransferFunction() instead */ DEPRECATED(void CreateOpacityTransferFunction(vtkPiecewiseFunction *&opacityFunction)); /** * \deprecatedSince{2014_03} Please use CreateGradientTransferFunction() instead */ DEPRECATED(void CreateGradientTransferFunction(vtkPiecewiseFunction *&gradientFunction)); vtkSmartPointer CreateColorTransferFunction(); vtkSmartPointer CreateOpacityTransferFunction(); vtkSmartPointer CreateGradientTransferFunction(); /** * @brief The LookupTableType enum for different predefined lookup tables. * * \li GRAYSCALE Our default level-window (sometimes referred to as window-level by other sources) setup for a test * image looks like this: * \image html ExampleLevelWindowColor.png * \li INVERSE_GRAYSCALE Inverse LookupTable of GRAYSCALE. * \li HOT_IRON A LookupTable for red colors. * \li JET A LookupTable for JET color rendering. * \li LEGACY_BINARY A LookupTable for binary images. * \li LEGACY_RAINBOW_COLOR A rainbow-like LookupTable. * \li MULTILABEL A LookupTable for multilabel images. * \li PET_COLOR A LookupTable for PET color rendering. * \li PET_20 A LookupTable for PET_20 color rendering. * * The different LookupTableTypes can be applied in the MitkWorkbench via right-clicking * on an image and choosing a color map. */ enum LookupTableType { GRAYSCALE, INVERSE_GRAYSCALE, HOT_IRON, JET, JET_TRANSPARENT, - Plasma, + PLASMA, LEGACY_BINARY, LEGACY_RAINBOW_COLOR, MULTILABEL, PET_COLOR, PET_20 }; static const char *const typenameList[]; /*! * \brief Set the look-up table type by enum (or integer). * \details Returns if the given type doesn't exist. Only changes the type if it is different * from the current one. */ virtual void SetType(const LookupTableType type); /*! * \brief Set the look-up table type by string. * \details Returns if the given type doesn't exist. Only changes the type if it is different * from the current one. */ virtual void SetType(const std::string &typeName); /*! * \brief Return the current look-up table type as a string. */ virtual const std::string GetActiveTypeAsString(); protected: void PrintSelf(std::ostream &os, itk::Indent indent) const override; LookupTable(const LookupTable &other); virtual void BuildGrayScaleLookupTable(); virtual void BuildLegacyBinaryLookupTable(); virtual void BuildLegacyRainbowColorLookupTable(); virtual void BuildInverseGrayScaleLookupTable(); virtual void BuildHotIronLookupTable(); virtual void BuildPlasmaLookupTable(); virtual void BuildJetLookupTable(bool transparent = false); virtual void BuildPETColorLookupTable(); virtual void BuildPET20LookupTable(); virtual void BuildMultiLabelLookupTable(); vtkSmartPointer m_LookupTable; float m_Window; float m_Level; float m_Opacity; LookupTableType m_type; private: itk::LightObject::Pointer InternalClone() const override; }; } // namespace mitk #endif /* mitkLookupTable_h */ diff --git a/Modules/Core/src/DataManagement/mitkLookupTable.cpp b/Modules/Core/src/DataManagement/mitkLookupTable.cpp index f3b0047b3d..194381ba02 100644 --- a/Modules/Core/src/DataManagement/mitkLookupTable.cpp +++ b/Modules/Core/src/DataManagement/mitkLookupTable.cpp @@ -1,605 +1,603 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkLookupTable.h" #include #include #include #include #include +#include #include #include #include - const char *const mitk::LookupTable::typenameList[] = { "Grayscale", "Inverse Grayscale", "Hot Iron", "Jet", "Jet Transparent", "Plasma", "Legacy Binary", "Legacy Rainbow Color", "Multilabel", "PET Color", "PET 20", "END_OF_ARRAY" // Do not add typenames after this entry (see QmitkDataManagerView::ColormapMenuAboutToShow()) }; mitk::LookupTable::LookupTable() : m_Window(0.0), m_Level(0.0), m_Opacity(1.0), m_type(mitk::LookupTable::GRAYSCALE) { m_LookupTable = vtkSmartPointer::New(); this->BuildGrayScaleLookupTable(); } mitk::LookupTable::LookupTable(const LookupTable &other) : itk::DataObject(), m_LookupTable(vtkSmartPointer::New()) { m_LookupTable->DeepCopy(other.m_LookupTable); } mitk::LookupTable::~LookupTable() { } void mitk::LookupTable::SetVtkLookupTable(vtkSmartPointer lut) { if ((!lut) || (m_LookupTable == lut)) { return; } m_LookupTable = lut; this->Modified(); } void mitk::LookupTable::SetType(const mitk::LookupTable::LookupTableType type) { if (m_type == type) return; switch (type) { case (mitk::LookupTable::GRAYSCALE): this->BuildGrayScaleLookupTable(); break; case (mitk::LookupTable::INVERSE_GRAYSCALE): this->BuildInverseGrayScaleLookupTable(); break; case (mitk::LookupTable::HOT_IRON): this->BuildHotIronLookupTable(); break; case (mitk::LookupTable::JET): this->BuildJetLookupTable(); break; case (mitk::LookupTable::JET_TRANSPARENT): this->BuildJetLookupTable(true); break; - case (mitk::LookupTable::Plasma): + case (mitk::LookupTable::PLASMA): this->BuildPlasmaLookupTable(); break; case (mitk::LookupTable::LEGACY_BINARY): this->BuildLegacyBinaryLookupTable(); break; case (mitk::LookupTable::MULTILABEL): this->BuildMultiLabelLookupTable(); break; case (mitk::LookupTable::PET_COLOR): this->BuildPETColorLookupTable(); break; case (mitk::LookupTable::PET_20): this->BuildPET20LookupTable(); break; case (mitk::LookupTable::LEGACY_RAINBOW_COLOR): this->BuildLegacyRainbowColorLookupTable(); break; default: MITK_ERROR << "non-existing colormap"; return; } m_type = type; } void mitk::LookupTable::SetType(const std::string &typeName) { int i = 0; std::string lutType = this->typenameList[i]; while (lutType != "END_OF_ARRAY") { if (lutType == typeName) { this->SetType(static_cast(i)); } lutType = this->typenameList[++i]; } } const std::string mitk::LookupTable::GetActiveTypeAsString() { return std::string(typenameList[(int)m_type]); } void mitk::LookupTable::ChangeOpacityForAll(float opacity) { int noValues = m_LookupTable->GetNumberOfTableValues(); double rgba[4]; for (int i = 0; i < noValues; i++) { m_LookupTable->GetTableValue(i, rgba); rgba[3] = opacity; m_LookupTable->SetTableValue(i, rgba); } this->Modified(); // need to call modified, since LookupTableProperty seems to be unchanged so no widget-update is // executed } void mitk::LookupTable::ChangeOpacity(int index, float opacity) { int noValues = m_LookupTable->GetNumberOfTableValues(); if (index > noValues) { MITK_INFO << "could not change opacity. index exceed size of lut ... " << std::endl; return; } double rgba[4]; m_LookupTable->GetTableValue(index, rgba); rgba[3] = opacity; m_LookupTable->SetTableValue(index, rgba); this->Modified(); // need to call modified, since LookupTableProperty seems to be unchanged so no widget-update is // executed } void mitk::LookupTable::GetColor(double value, double rgb[3]) { this->GetVtkLookupTable()->GetColor(value, rgb); } void mitk::LookupTable::GetTableValue(int index, double rgba[4]) { this->GetVtkLookupTable()->GetTableValue(index, rgba); } void mitk::LookupTable::SetTableValue(int index, double rgba[4]) { this->GetVtkLookupTable()->SetTableValue(index, rgba); } vtkSmartPointer mitk::LookupTable::GetVtkLookupTable() const { return m_LookupTable; } mitk::LookupTable::RawLookupTableType *mitk::LookupTable::GetRawLookupTable() const { return m_LookupTable->GetPointer(0); } /*! * \brief equality operator inplementation */ bool mitk::LookupTable::operator==(const mitk::LookupTable &other) const { if (m_LookupTable == other.GetVtkLookupTable()) return true; vtkLookupTable *olut = other.GetVtkLookupTable(); if (olut == nullptr) return false; bool equal = (m_LookupTable->GetNumberOfColors() == olut->GetNumberOfColors()) && (m_LookupTable->GetTableRange()[0] == olut->GetTableRange()[0]) && (m_LookupTable->GetTableRange()[1] == olut->GetTableRange()[1]) && (m_LookupTable->GetHueRange()[0] == olut->GetHueRange()[0]) && (m_LookupTable->GetHueRange()[1] == olut->GetHueRange()[1]) && (m_LookupTable->GetSaturationRange()[0] == olut->GetSaturationRange()[0]) && (m_LookupTable->GetSaturationRange()[1] == olut->GetSaturationRange()[1]) && (m_LookupTable->GetValueRange()[0] == olut->GetValueRange()[0]) && (m_LookupTable->GetValueRange()[1] == olut->GetValueRange()[1]) && (m_LookupTable->GetAlphaRange()[0] == olut->GetAlphaRange()[0]) && (m_LookupTable->GetAlphaRange()[1] == olut->GetAlphaRange()[1]) && (m_LookupTable->GetRamp() == olut->GetRamp()) && (m_LookupTable->GetScale() == olut->GetScale()) && (m_LookupTable->GetAlpha() == olut->GetAlpha()) && (m_LookupTable->GetTable()->GetNumberOfTuples() == olut->GetTable()->GetNumberOfTuples()); if (equal == false) return false; for (vtkIdType i = 0; i < m_LookupTable->GetNumberOfTableValues(); i++) { bool tvequal = (m_LookupTable->GetTableValue(i)[0] == olut->GetTableValue(i)[0]) && (m_LookupTable->GetTableValue(i)[1] == olut->GetTableValue(i)[1]) && (m_LookupTable->GetTableValue(i)[2] == olut->GetTableValue(i)[2]) && (m_LookupTable->GetTableValue(i)[3] == olut->GetTableValue(i)[3]); if (tvequal == false) return false; } return true; } /*! * \brief un-equality operator implementation */ bool mitk::LookupTable::operator!=(const mitk::LookupTable &other) const { return !(*this == other); } /*! * \brief assignment operator implementation */ mitk::LookupTable &mitk::LookupTable::operator=(const mitk::LookupTable &LookupTable) { if (this == &LookupTable) { return *this; } else { m_LookupTable = LookupTable.GetVtkLookupTable(); return *this; } } void mitk::LookupTable::UpdateOutputInformation() { if (this->GetSource()) { this->GetSource()->UpdateOutputInformation(); } } void mitk::LookupTable::SetRequestedRegionToLargestPossibleRegion() { } bool mitk::LookupTable::RequestedRegionIsOutsideOfTheBufferedRegion() { return false; } bool mitk::LookupTable::VerifyRequestedRegion() { // normally we should check if the requested region lies within the // largest possible region. Since for lookup-tables we assume, that the // requested region is always the largest possible region, we can always // return true! return true; } void mitk::LookupTable::SetRequestedRegion(const itk::DataObject *) { // not implemented, since we always want to have the RequestedRegion // to be set to LargestPossibleRegion } vtkSmartPointer mitk::LookupTable::CreateColorTransferFunction() { vtkSmartPointer colorFunction = vtkSmartPointer::New(); mitk::LookupTable::RawLookupTableType *rawLookupTable = this->GetRawLookupTable(); int num_of_values = m_LookupTable->GetNumberOfTableValues(); auto cols = new double[3 * num_of_values]; double *colsHead = cols; for (int i = 0; i < num_of_values; ++i) { *cols = static_cast(*rawLookupTable) / 255.0; ++cols; ++rawLookupTable; *cols = static_cast(*rawLookupTable) / 255.0; ++cols; ++rawLookupTable; *cols = static_cast(*rawLookupTable) / 255.0; ++cols; ++rawLookupTable; ++rawLookupTable; } colorFunction->BuildFunctionFromTable( m_LookupTable->GetTableRange()[0], m_LookupTable->GetTableRange()[1], num_of_values, colsHead); return colorFunction; } void mitk::LookupTable::CreateColorTransferFunction(vtkColorTransferFunction *&colorFunction) { colorFunction = this->CreateColorTransferFunction(); } vtkSmartPointer mitk::LookupTable::CreateOpacityTransferFunction() { vtkSmartPointer opacityFunction = vtkSmartPointer::New(); mitk::LookupTable::RawLookupTableType *rgba = this->GetRawLookupTable(); int num_of_values = m_LookupTable->GetNumberOfTableValues(); auto alphas = new double[num_of_values]; double *alphasHead = alphas; rgba += 3; for (int i = 0; i < num_of_values; ++i) { *alphas = static_cast(*rgba) / 255.0; ++alphas; rgba += 4; } opacityFunction->BuildFunctionFromTable( m_LookupTable->GetTableRange()[0], m_LookupTable->GetTableRange()[1], num_of_values, alphasHead); return opacityFunction; } void mitk::LookupTable::CreateOpacityTransferFunction(vtkPiecewiseFunction *&opacityFunction) { opacityFunction = this->CreateOpacityTransferFunction(); } vtkSmartPointer mitk::LookupTable::CreateGradientTransferFunction() { vtkSmartPointer gradientFunction = vtkSmartPointer::New(); mitk::LookupTable::RawLookupTableType *rgba = this->GetRawLookupTable(); int num_of_values = m_LookupTable->GetNumberOfTableValues(); auto alphas = new double[num_of_values]; double *alphasHead = alphas; rgba += 3; for (int i = 0; i < num_of_values; ++i) { *alphas = static_cast(*rgba) / 255.0; ++alphas; rgba += 4; } gradientFunction->BuildFunctionFromTable( m_LookupTable->GetTableRange()[0], m_LookupTable->GetTableRange()[1], num_of_values, alphasHead); return gradientFunction; } void mitk::LookupTable::CreateGradientTransferFunction(vtkPiecewiseFunction *&gradientFunction) { gradientFunction = this->CreateGradientTransferFunction(); } void mitk::LookupTable::PrintSelf(std::ostream &os, itk::Indent indent) const { os << indent; m_LookupTable->PrintHeader(os, vtkIndent()); } itk::LightObject::Pointer mitk::LookupTable::InternalClone() const { itk::LightObject::Pointer result(new Self(*this)); result->UnRegister(); return result; } void mitk::LookupTable::BuildGrayScaleLookupTable() { vtkSmartPointer lut = vtkSmartPointer::New(); lut->SetRampToLinear(); lut->SetSaturationRange(0.0, 0.0); lut->SetHueRange(0.0, 0.0); lut->SetValueRange(0.0, 1.0); lut->Build(); m_LookupTable = lut; this->Modified(); } void mitk::LookupTable::BuildLegacyBinaryLookupTable() { vtkSmartPointer lut = vtkSmartPointer::New(); lut->SetRampToLinear(); lut->SetSaturationRange(0.0, 0.0); lut->SetHueRange(0.0, 0.0); lut->SetValueRange(0.0, 1.0); lut->Build(); lut->SetTableValue(0, 0.0, 0.0, 0.0, 0.0); m_LookupTable = lut; this->Modified(); } void mitk::LookupTable::BuildInverseGrayScaleLookupTable() { vtkSmartPointer lut = vtkSmartPointer::New(); lut->SetTableRange(0, 1); lut->SetSaturationRange(0, 0); lut->SetHueRange(0, 0); lut->SetValueRange(1, 0); lut->SetAlphaRange(1, 0); lut->Build(); m_LookupTable = lut; this->Modified(); } void mitk::LookupTable::BuildHotIronLookupTable() { vtkSmartPointer lut = vtkSmartPointer::New(); lut->SetNumberOfTableValues(256); lut->Build(); for (int i = 0; i < 256; i++) { lut->SetTableValue( i, (double)HotIron[i][0] / 255.0, (double)HotIron[i][1] / 255.0, (double)HotIron[i][2] / 255.0, 1.0); } m_LookupTable = lut; this->Modified(); } void mitk::LookupTable::BuildJetLookupTable(bool transparent) { vtkSmartPointer lut = vtkSmartPointer::New(); lut->SetNumberOfTableValues(256); lut->Build(); int i = 0; if (transparent) { // Lowest intensity is transparent lut->SetTableValue(0, (double)Jet[0][0] / 255.0, (double)Jet[0][1] / 255.0, (double)Jet[0][2] / 255.0, 0.0); i = 1; } for (; i < 256; i++) { lut->SetTableValue(i, (double)Jet[i][0] / 255.0, (double)Jet[i][1] / 255.0, (double)Jet[i][2] / 255.0, 1.0); } m_LookupTable = lut; this->Modified(); } - void mitk::LookupTable::BuildPETColorLookupTable() { vtkSmartPointer lut = vtkSmartPointer::New(); lut->SetNumberOfTableValues(256); lut->SetTableRange((m_Level - m_Window / 2.0), (m_Level + m_Window / 2.0)); lut->Build(); for (int i = 0; i < 256; i++) { lut->SetTableValue( i, (double)PETColor[i][0] / 255.0, (double)PETColor[i][1] / 255.0, (double)PETColor[i][2] / 255.0, 1.0); } m_LookupTable = lut; this->Modified(); } void mitk::LookupTable::BuildPET20LookupTable() { vtkSmartPointer lut = vtkSmartPointer::New(); lut->SetNumberOfTableValues(256); lut->SetTableRange((m_Level - m_Window / 2.0), (m_Level + m_Window / 2.0)); lut->Build(); for (int i = 0; i < 256; i++) { lut->SetTableValue(i, (double)PET20[i][0] / 255.0, (double)PET20[i][1] / 255.0, (double)PET20[i][2] / 255.0, 1.0); } m_LookupTable = lut; this->Modified(); } void mitk::LookupTable::BuildMultiLabelLookupTable() { vtkSmartPointer lut = vtkSmartPointer::New(); lut->SetNumberOfTableValues(65536); lut->SetTableRange(0, 65536); lut->SetTableValue(0, 0.0, 0.0, 0.0, 0.0); // background lut->SetTableValue(1, 1.0, 1.0, 0.0, 0.4); lut->SetTableValue(2, 0.0, 1.0, 0.0, 0.4); lut->SetTableValue(3, 0.0, 0.0, 1.0, 0.4); lut->SetTableValue(4, 1.0, 1.0, 0.4, 0.4); lut->SetTableValue(5, 0.0, 0.4, 0.7, 0.4); lut->SetTableValue(6, 1.0, 0.0, 1.0, 0.4); lut->SetTableValue(7, 1.0, 0.5, 0.0, 0.4); lut->SetTableValue(8, 0.0, 1.0, 0.5, 0.4); lut->SetTableValue(9, 0.5, 0.0, 1.0, 0.4); lut->SetTableValue(10, 1.0, 1.0, 0.5, 0.4); lut->SetTableValue(11, 0.5, 1.0, 1.0, 0.4); lut->SetTableValue(12, 1.0, 0.5, 0.6, 0.4); lut->SetTableValue(13, 1.0, 0.3, 0.3, 0.4); lut->SetTableValue(14, 0.4, 0.7, 1.0, 0.4); lut->SetTableValue(15, 0.4, 0.5, 1.0, 0.4); lut->SetTableValue(16, 0.8, 0.5, 1.0, 0.4); lut->SetTableValue(17, 1.0, 0.3, 1.0, 0.4); lut->SetTableValue(18, 1.0, 0.5, 0.6, 0.4); lut->SetTableValue(19, 1.0, 0.5, 0.4, 0.4); lut->SetTableValue(20, 0.4, 0.5, 0.4, 0.4); lut->SetTableValue(21, 1.0, 0.5, 0.76, 0.4); lut->SetTableValue(22, 0.76, 0.4, 0.4, 0.4); lut->SetTableValue(23, 1.0, 0.5, 0.4, 0.4); lut->SetTableValue(24, 0.76, 0.3, 0.4, 0.4); lut->SetTableValue(25, 1.0, 0.3, 0.4, 0.4); for (int i = 26; i < 65536; i++) { if (i % 12 == 0) lut->SetTableValue(i, 1.0, 0.0, 0.0, 0.4); else if (i % 12 == 1) lut->SetTableValue(i, 0.0, 1.0, 0.0, 0.4); else if (i % 12 == 2) lut->SetTableValue(i, 0.0, 0.0, 1.0, 0.4); else if (i % 12 == 3) lut->SetTableValue(i, 1.0, 1.0, 0.0, 0.4); else if (i % 12 == 4) lut->SetTableValue(i, 0.0, 1.0, 1.0, 0.4); else if (i % 12 == 5) lut->SetTableValue(i, 1.0, 0.0, 1.0, 0.4); else if (i % 12 == 6) lut->SetTableValue(i, 1.0, 0.5, 0.0, 0.4); else if (i % 12 == 7) lut->SetTableValue(i, 0.0, 1.0, 0.5, 0.4); else if (i % 12 == 8) lut->SetTableValue(i, 0.5, 0.0, 1.0, 0.4); else if (i % 12 == 9) lut->SetTableValue(i, 1.0, 1.0, 0.5, 0.4); else if (i % 12 == 10) lut->SetTableValue(i, 0.5, 1.0, 1.0, 0.4); else if (i % 12 == 11) lut->SetTableValue(i, 1.0, 0.5, 1.0, 0.4); } m_LookupTable = lut; this->Modified(); } void mitk::LookupTable::BuildLegacyRainbowColorLookupTable() { vtkSmartPointer lut = vtkSmartPointer::New(); lut->SetRampToLinear(); lut->SetHueRange(0.6667, 0.0); lut->SetTableRange(0.0, 20.0); lut->Build(); m_LookupTable = lut; this->Modified(); } - void mitk::LookupTable::BuildPlasmaLookupTable() { vtkSmartPointer lut = vtkSmartPointer::New(); lut->SetNumberOfTableValues(256); lut->Build(); for (int i = 0; i < 256; i++) { lut->SetTableValue( - i, (double)HotIron[i][0] / 255.0, (double)HotIron[i][1] / 255.0, (double)HotIron[i][2] / 255.0, 1.0); + i, (double)Plasma[i][0] / 255.0, (double)Plasma[i][1] / 255.0, (double)Plasma[i][2] / 255.0, 1.0); } m_LookupTable = lut; this->Modified(); } \ No newline at end of file