imageDemo.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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_QT
  24. showImage ( srcColor );
  25. #else
  26. cerr << "Visualization disabled: no QT library available" << endl;
  27. #endif
  28. // simple grayvalue image
  29. Image src;
  30. rgbToGray ( srcColor, &src );
  31. // convert the color image to a grayvalue image
  32. // first demonstration: some simple filters
  33. // using the FilterT interface
  34. FloatImage gradient;
  35. FilterT<unsigned char, float, float>::gradientStrength( src, gradient );
  36. ColorImage gradientColor;
  37. imageToPseudoColor ( gradient, gradientColor );
  38. #ifdef NICE_USELIB_QT
  39. showImage ( gradientColor );
  40. #endif
  41. }