123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- /**
- * @file ICETools.cpp
- * @brief simple ICE GUI tools
- * @author Erik Rodner
- * @date 03/13/2008
- */
- #include "core/basics/Exception.h"
- #include "core/vector/VectorT.h"
- #include "core/vector/MatrixT.h"
- #include "core/image/ImageT.h"
- #include "core/image/Convert.h"
- #include "core/image/RectT.h"
- #include "core/imagedisplay/ImageDisplay.h"
- #include "vislearning/baselib/ICETools.h"
- #include <iostream>
- using namespace OBJREC;
- using namespace std;
- //using namespace NICE;
- ICETools::ICETools()
- {
- }
- ICETools::~ICETools()
- {
- }
- void ICETools::selectRectangles ( const NICE::Image & panel, NICE::Image & overlay, vector<NICE::Vector> & x, int color )
- {
- fthrow ( NICE::Exception, "ICETools::selectRectangles -- not yet implemented due to old ICE version." );
- }
- void ICETools::selectPoints ( const NICE::Image & panel, NICE::Image & overlay, vector<NICE::Vector> & x, int color )
- {
- fthrow ( NICE::Exception, "ICETools::selectPoints -- not yet implemented due to old ICE version." );
- }
- void ICETools::convertToRGB ( const NICE::Matrix & m, NICE::ColorImage & img )
- {
- matrixToPseudoColor(m, img);
- }
- void ICETools::convertToRGB ( const NICE::FloatImage & m, NICE::ColorImage & img )
- {
- imageToPseudoColor(m, img);
- }
- void ICETools::calcGrayImage ( const NICE::ColorImage & img, NICE::Image & imgg )
- {
- imgg.resize ( img.width(), img.height() );
- for ( int y = 0 ; y < img.height(); y++ )
- for ( int x = 0 ; x < img.width() ; x++ )
- {
- unsigned char g = ( unsigned char ) ( 0.299 * img.getPixel ( x, y, 0 ) +
- 0.587 * img.getPixel ( x, y, 1 ) + 0.114 * img.getPixel ( x, y, 2 ) );
- imgg.setPixel ( x, y, g );
- }
- }
- double *ICETools::convertICE2M ( const NICE::Matrix & M )
- {
- double *raw = new double [ M.rows() * M.cols() ];
- long index = 0;
- for ( uint i = 0 ; i < M.rows() ; i++ )
- for ( uint j = 0 ; j < M.cols() ; j++, index++ )
- raw[index] = M ( i, j );
- return raw;
- }
- void ICETools::convertM2ICE ( NICE::Matrix & M, double *raw )
- {
- long index = 0;
- for ( int i = 0 ; i < ( int ) M.rows() ; i++ )
- for ( int j = 0 ; j < ( int ) M.cols() ; j++, index++ )
- M ( i, j ) = raw[index];
- }
- #ifndef NOVISUAL
- int ICETools::markImage ( const NICE::Image & img, NICE::Image & mark, int marksize, int color )
- {
- fprintf ( stderr, "ICETools::markImage: reimplement this function for NICE\n" );
- exit ( -1 );
- return 0;
- }
- int ICETools::showImages ( vector<NICE::Image> & imagelist )
- {
- #ifndef NOVISUAL
- for ( size_t j = 0 ; j < imagelist.size() ; j++ )
- {
- showImage ( imagelist[j] );
- }
- #endif
- int xsize = imagelist[0].width();
- int ysize = imagelist[0].height();
- int n = imagelist.size();
- int n1 = ( int ) sqrt ( (double)n );
- int n2 = n / n1 + 1;
- NICE::Image img ( n1*xsize, n2*ysize );
- img.set ( 0 );
- int k = 0;
- for ( int j = 0 ; j < n2 ; j++ )
- for ( int i = 0 ; i < n1 ; i++, k++ )
- if ( k >= n ) break;
- else {
- for ( int y = 0 ; y < imagelist[k].height(); y++ )
- for ( int x = 0 ; x < imagelist[k].width(); x++ )
- {
- img.setPixel ( i*xsize + x, j*ysize + y,
- imagelist[k].getPixel ( x, y ) );
- }
- }
- img.write ( "display.bmp" );
- getchar();
- return 0;
- }
- #endif
|