浏览代码

minor changes

Erik Rodner 13 年之前
父节点
当前提交
56ae46465b
共有 2 个文件被更改,包括 6 次插入88 次删除
  1. 3 85
      baselib/ICETools.cpp
  2. 3 3
      baselib/ICETools.h

+ 3 - 85
baselib/ICETools.cpp

@@ -10,6 +10,7 @@
 #include "core/vector/MatrixT.h"
 #include "core/vector/MatrixT.h"
 #include <core/imagedisplay/ImageDisplay.h>
 #include <core/imagedisplay/ImageDisplay.h>
 #include <core/image/Filter.h>
 #include <core/image/Filter.h>
+#include <core/image/Convert.h>
 
 
 #include <iostream>
 #include <iostream>
 
 
@@ -100,97 +101,14 @@ void ICETools::selectPoints ( const NICE::Image & panel, NICE::Image & overlay,
 
 
 }
 }
 
 
-void ICETools::toColor ( double x, double & r, double & g, double & b )
-{
-  size_t seg = ( size_t ) ( x * 6.0 );
-  double y   = ( 6 * x - seg );
-
-  switch ( seg ) {
-    case 0:
-      r = 0.0;
-      g = 0.0;
-      b = y;
-      break;
-    case 1:
-      r = 0.0;
-      g =  y;
-      b = 1.0;
-      break;
-    case 2:
-      r = 0.0;
-      g = 1.0;
-      b = 1.0 - y;
-      break;
-    case 3:
-      r =  y;
-      g = 1.0;
-      b = 0.0;
-      break;
-    case 4:
-      r = 1.0;
-      g = 1.0 - y;
-      b = 0.0;
-      break;
-    case 5:
-      r = 1.0;
-      g = y;
-      b = y;
-      break;
-    default:
-      r = 1.0;
-      g = 1.0;
-      b = 1.0;
-      break;
-  }
-}
-
 void ICETools::convertToRGB ( const NICE::Matrix & m, NICE::ColorImage & img )
 void ICETools::convertToRGB ( const NICE::Matrix & m, NICE::ColorImage & img )
 {
 {
-  img.resize ( m.cols(), m.rows() );
-  double max = - numeric_limits<double>::max();
-  double min = numeric_limits<double>::max();
-  for ( size_t x = 0 ; x < ( size_t ) m.cols(); x++ )
-    for ( size_t y = 0 ; y < ( size_t ) m.rows() ; y++ )
-    {
-      if ( m ( y, x ) > max ) max = m ( y, x );
-      if ( m ( y, x ) < min ) min = m ( y, x );
-    }
-cout << "max: " << max << " min: " << min << endl;
-  for ( size_t y = 0 ; y < ( size_t ) m.rows() ; y++ )
-    for ( size_t x = 0 ; x < ( size_t ) m.cols(); x++ )
-    {
-      double val = ( m ( y, x ) - min ) / ( max - min );
-      double r, g, b;
-      toColor ( val, r, g, b );
-      img.setPixel ( x, y, 0, ( int ) ( r*255 ) );
-      img.setPixel ( x, y, 1, ( int ) ( g*255 ) );
-      img.setPixel ( x, y, 2, ( int ) ( b*255 ) );
-    }
+  matrixToPseudoColor(m, img);
 }
 }
 
 
 void ICETools::convertToRGB ( const NICE::FloatImage & m, NICE::ColorImage & img )
 void ICETools::convertToRGB ( const NICE::FloatImage & m, NICE::ColorImage & img )
 {
 {
-  img.resize ( m.width(), m.height() );
-  double max = - numeric_limits<double>::max();
-  double min = numeric_limits<double>::max();
-  for ( size_t x = 0 ; x < ( size_t ) m.width(); x++ )
-    for ( size_t y = 0 ; y < ( size_t ) m.height() ; y++ )
-    {
-      double v = m.getPixel ( x, y );
-      if ( v > max ) max = v;
-      if ( v < min ) min = v;
-    }
-
-  for ( size_t y = 0 ; y < ( size_t ) m.height() ; y++ )
-    for ( size_t x = 0 ; x < ( size_t ) m.width(); x++ )
-    {
-      double val = ( m.getPixel ( x, y ) - min ) / ( max - min );
-      double r, g, b;
-      toColor ( val, r, g, b );
-      img.setPixel ( x, y, 0, ( int ) ( r*255 ) );
-      img.setPixel ( x, y, 1, ( int ) ( g*255 ) );
-      img.setPixel ( x, y, 2, ( int ) ( b*255 ) );
-    }
+  imageToPseudoColor(m, img);
 }
 }
 
 
 void ICETools::calcGrayImage ( const NICE::ColorImage & img, NICE::Image & imgg )
 void ICETools::calcGrayImage ( const NICE::ColorImage & img, NICE::Image & imgg )

+ 3 - 3
baselib/ICETools.h

@@ -49,19 +49,19 @@ class ICETools
     static void selectPoints ( const NICE::Image & panel, NICE::Image & overlay,
     static void selectPoints ( const NICE::Image & panel, NICE::Image & overlay,
                                std::vector<NICE::Vector> & x, int color );
                                std::vector<NICE::Vector> & x, int color );
 
 
-    /** convert a double image to a pseudocolor rgb image
+    /** convert a double image to a pseudocolor rgb image (DEPRECATED)
         @param m input double image
         @param m input double image
         @param img resulting pseudocolor rgb image
         @param img resulting pseudocolor rgb image
     */
     */
     static void convertToRGB ( const NICE::FloatImage & m, NICE::ColorImage & img );
     static void convertToRGB ( const NICE::FloatImage & m, NICE::ColorImage & img );
 
 
-    /** convert a matrix to a pseudocolor rgb image
+    /** convert a matrix to a pseudocolor rgb image (DEPRECATED)
         @param m input double image
         @param m input double image
         @param img resulting pseudocolor rgb image
         @param img resulting pseudocolor rgb image
     */
     */
     static void convertToRGB ( const NICE::Matrix & m, NICE::ColorImage & img );
     static void convertToRGB ( const NICE::Matrix & m, NICE::ColorImage & img );
 
 
-    /** convert a single double value to a pseudocolor
+    /** convert a single double value to a pseudocolor (DEPRECATED)
         @param x input double value
         @param x input double value
         @param r resulting red value
         @param r resulting red value
         @param g resulting green value
         @param g resulting green value