convertImageNice.cpp 613 B

123456789101112131415161718192021222324252627
  1. #include <iostream>
  2. #include <core/image/ImageT.h>
  3. using namespace NICE;
  4. using namespace std;
  5. int main ( int argc, char **argv )
  6. {
  7. cout << "converting and cropping (not resizing!) tool (c) Erik Rodner, 2011" << endl;
  8. if ( (argc != 3) && (argc != 5) ) {
  9. cerr << "usage: " << argv[0] << " <src> <dst> [width] [height]" << endl;
  10. exit(-1);
  11. }
  12. ColorImage src ( argv[1] );
  13. if ( argc == 3 )
  14. {
  15. src.write(argv[2]);
  16. } else {
  17. int xsize = std::min( atoi(argv[3]), src.width() );
  18. int ysize = std::min( atoi(argv[4]), src.height() );
  19. src.createSubImage(Rect(0,0,xsize,ysize))->write ( argv[2] );
  20. }
  21. }