imageDemo.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /** demonstrations program for the image routines
  2. * in the nice/core library */
  3. #include <iostream>
  4. #include <core/image/ImageT.h>
  5. #include <core/image/FilterT.h>
  6. // QT Interface for image display
  7. // We only use the simple function showImage in this example, but there is far more
  8. // to explore in this area.
  9. #ifdef NICE_USELIB_QT
  10. #include <core/imagedisplay/ImageDisplay.h>
  11. #endif
  12. using namespace NICE;
  13. using namespace std;
  14. int main ( int argc, char **argv )
  15. {
  16. if ( (argc != 2) ) {
  17. cerr << "usage: " << argv[0] << " <image>" << endl;
  18. exit(-1);
  19. }
  20. // read a color image
  21. ColorImage srcColor ( argv[1] );
  22. // show the image and wait for the window being closed manually
  23. #ifdef NICE_USELIB_GLUT
  24. #ifdef NICE_USELIB_QT
  25. showImage ( srcColor );
  26. #else
  27. cerr << "Visualization disabled: no QT library available" << endl;
  28. #endif
  29. #else
  30. cerr << "Visualization disabled: no GLUT library available" << endl;
  31. #endif
  32. // simple grayvalue image
  33. Image src;
  34. rgbToGray ( srcColor, &src );
  35. // convert the color image to a grayvalue image
  36. // first demonstration: some simple filters
  37. // using the FilterT interface
  38. FloatImage gradient;
  39. FilterT<unsigned char, float, float>::gradientStrength( src, gradient );
  40. ColorImage gradientColor;
  41. imageToPseudoColor ( gradient, gradientColor );
  42. #ifdef NICE_USELIB_GLUT
  43. #ifdef NICE_USELIB_QT
  44. showImage ( gradientColor );
  45. #endif
  46. #endif
  47. }