|
@@ -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 )
|