Index: mitkGeometry2DDataVtkMapper3D.cpp
===================================================================
--- mitkGeometry2DDataVtkMapper3D.cpp	(revision 26968)
+++ mitkGeometry2DDataVtkMapper3D.cpp	(working copy)
@@ -24,6 +24,7 @@
 #include "mitkVtkRepresentationProperty.h"
 #include "mitkWeakPointerProperty.h"
 #include "mitkNodePredicateDataType.h"
+#include "mitkPixelType.h"
 
 #include <vtkAssembly.h>
 #include <vtkDataSetMapper.h>
@@ -40,6 +41,10 @@
 #include <vtkTransformPolyDataFilter.h>
 #include <vtkTubeFilter.h>
 
+#include "vtkMitkApllyLevelWindowToRGBFilter.h"
+#include <vtkImageRGBToHSI.h>
+#include <vtkImageHSIToRGB.h>
+
 namespace mitk
 {
 
@@ -674,10 +679,24 @@
 
             // VTK (mis-)interprets unsigned char (binary) images as color images;
             // So, we must manually turn on their mapping through a (gray scale) lookup table;
-            if( binary ) 
+            mitk::PixelType pixelType = (dynamic_cast<mitk::Image*>(node->GetData()))->GetPixelType();
+            if( pixelType.GetBitsPerComponent() == pixelType.GetBpe() ) 
+            {              
               texture->MapColorScalarsThroughLookupTableOn();
+            }
             else
+            {
               texture->MapColorScalarsThroughLookupTableOff();
+              vtkMitkApllyLevelWindowToRGBFilter* levelWindowToRGBFilterObject = new vtkMitkApllyLevelWindowToRGBFilter();
+              levelWindowToRGBFilterObject->SetLookupTable(texture->GetLookupTable());
+              vtkImageRGBToHSI* rgbToHSIFilter = vtkImageRGBToHSI::New();
+              rgbToHSIFilter->SetInput( rit->m_Image );
+              rgbToHSIFilter->Update();
+              levelWindowToRGBFilterObject->SetInput(rgbToHSIFilter->GetOutput());
+              vtkImageHSIToRGB* hsiToRGBFilter = vtkImageHSIToRGB::New();
+              hsiToRGBFilter->SetInput(levelWindowToRGBFilterObject->GetOutput());
+              texture->SetInput(hsiToRGBFilter->GetOutput());
+            }
 
             if( binary )
             {
Index: vtkMitkApllyLevelWindowToRGBFilter.cpp
===================================================================
--- vtkMitkApllyLevelWindowToRGBFilter.cpp	(revision 0)
+++ vtkMitkApllyLevelWindowToRGBFilter.cpp	(revision 0)
@@ -0,0 +1,141 @@
+/*=========================================================================
+
+Program:   Medical Imaging & Interaction Toolkit
+Language:  C++
+Date:      $Date$
+Version:   $Revision$
+
+Copyright (c) German Cancer Research Center, Division of Medical and
+Biological Informatics. All rights reserved.
+See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.
+
+This software is distributed WITHOUT ANY WARRANTY; without even
+the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+PURPOSE.  See the above copyright notices for more information.
+
+=========================================================================*/
+
+#include "vtkMitkApllyLevelWindowToRGBFilter.h"
+#include <vtkImageRGBToHSI.h>
+#include <vtkImageData.h>
+#include <vtkImageRGBToHSI.h>
+#include <vtkImageIterator.h>
+#include <vtkImageProgressIterator.h>
+#include <vtkLookupTable.h>
+
+vtkMitkApllyLevelWindowToRGBFilter::vtkMitkApllyLevelWindowToRGBFilter()
+{
+  
+}
+
+vtkMitkApllyLevelWindowToRGBFilter::~vtkMitkApllyLevelWindowToRGBFilter()
+{
+  
+}
+
+void vtkMitkApllyLevelWindowToRGBFilter::SetLookupTable(vtkScalarsToColors *lookupTable)
+{
+  m_LookupTable = lookupTable;
+}
+
+vtkScalarsToColors* vtkMitkApllyLevelWindowToRGBFilter::GetLookupTable()
+{
+  return m_LookupTable;
+}
+
+//----------------------------------------------------------------------------
+// This templated function executes the filter for any type of data.
+template <class T>
+void vtkCalculateIntensityFromLookupTable(vtkMitkApllyLevelWindowToRGBFilter *self,
+                             vtkImageData *inData,
+                             vtkImageData *outData,
+                             int outExt[6], T *)
+{
+  vtkImageIterator<T> inIt(inData, outExt);
+  vtkImageIterator<T> outIt(outData, outExt);
+  vtkLookupTable* lookupTable;
+  int idxC, maxC;
+  double H, S, I, Imin, Imax;
+  double imgRange[2];
+  double tableRange[2];
+  
+  // find the region to loop over
+  maxC = inData->GetNumberOfScalarComponents()-1;
+  Imin = 255;
+  Imax = 0;
+  // Loop through ouput pixels
+  while (!outIt.IsAtEnd())
+    {
+    T* inSI = inIt.BeginSpan();
+    T* outSI = outIt.BeginSpan();
+    T* outSIEnd = outIt.EndSpan();
+    while (outSI != outSIEnd)
+      {
+      // Pixel operation
+      H = static_cast<double>(*inSI); inSI++;
+      S = static_cast<double>(*inSI); inSI++;
+      I = static_cast<double>(*inSI); inSI++;
+      
+#if ( ( VTK_MAJOR_VERSION >= 5 ) && ( VTK_MINOR_VERSION>=2)  )
+      lookupTable = dynamic_cast<vtkLookupTable*>(self->GetLookupTable());
+#else
+      lookupTable = self->GetLookupTable();
+#endif
+      
+      lookupTable->GetTableRange(tableRange);
+      inData->GetScalarRange(imgRange);
+
+      I = ((I - tableRange[0]) / ( tableRange[1] - tableRange[0] )) * imgRange[1];
+      I = (I < imgRange[0] ? imgRange[0] : I);
+      I = (I > imgRange[1] ? imgRange[1] : I);
+
+      // assign output.
+      *outSI = static_cast<T>(H); outSI++;
+      *outSI = static_cast<T>(S); outSI++;
+      *outSI = static_cast<T>(I); outSI++;
+      
+      for (idxC = 3; idxC <= maxC; idxC++)
+        {
+        *outSI++ = *inSI++;
+        }
+      }
+    inIt.NextSpan();
+    outIt.NextSpan();
+    }
+}
+
+void vtkMitkApllyLevelWindowToRGBFilter::ExecuteInformation()
+{
+  vtkImageData *input = this->GetInput();
+  vtkImageData *output = this->GetOutput();
+
+  if (!input)
+  {
+    vtkErrorMacro(<< "Input not set.");
+    return;
+  }
+  output->CopyTypeSpecificInformation( input );
+
+  int extent[6];
+  input->GetWholeExtent(extent);
+  output->SetExtent(extent);
+  output->SetWholeExtent(extent);
+  output->SetUpdateExtent(extent);      
+  output->AllocateScalars();
+
+  switch (input->GetScalarType())
+    {
+    vtkTemplateMacro(
+      vtkCalculateIntensityFromLookupTable( this, input, 
+                               output, extent, 
+                               static_cast<VTK_TT *>(0)));
+    default:
+      vtkErrorMacro(<< "Execute: Unknown ScalarType");
+      return;
+    }  
+}
+
+void vtkMitkApllyLevelWindowToRGBFilter::ExecuteInformation(
+           vtkImageData *vtkNotUsed(inData), vtkImageData *vtkNotUsed(outData))
+{
+}

Property changes on: vtkMitkApllyLevelWindowToRGBFilter.cpp
___________________________________________________________________
Added: svn:keywords
   + Author Date Id Revision
Added: svn:eol-style
   + native

