Conversions.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /**
  2. * @file Conversions.cpp
  3. * @brief boring conversions
  4. * @author Erik Rodner
  5. * @date 02/19/2008
  6. */
  7. #include "core/image/ImageT.h"
  8. #include "core/vector/VectorT.h"
  9. #include "core/vector/MatrixT.h"
  10. #include <iostream>
  11. #include <assert.h>
  12. #include "vislearning/baselib/Conversions.h"
  13. using namespace OBJREC;
  14. using namespace std;
  15. using namespace NICE;
  16. Conversions::Conversions()
  17. {
  18. }
  19. Conversions::~Conversions()
  20. {
  21. }
  22. vector<double> Conversions::stl_vector ( const NICE::Vector & x )
  23. {
  24. vector<double> y;
  25. for ( size_t i = 0 ; i < x.size(); i++ )
  26. y.push_back(x[i]);
  27. return y;
  28. }
  29. void Conversions::resizeImage ( const NICE::Image & src, NICE::Image & dst, int newWidth, int newHeight )
  30. {
  31. int nw = newWidth;
  32. int nh = newHeight;
  33. if ( nw <= 0 ) {
  34. assert ( nh > 0.0 );
  35. nw = nh * src.width() / src.height();
  36. }
  37. if ( nh <= 0 ) {
  38. nh = nw * src.height() / src.width();
  39. }
  40. dst.resize(nw, nh);
  41. NICE::scale ( src, &dst );
  42. }
  43. void Conversions::resizeImage ( const NICE::ColorImage & src, NICE::ColorImage & dst, int newWidth, int newHeight )
  44. {
  45. int nw = newWidth;
  46. int nh = newHeight;
  47. if ( nw <= 0 ) {
  48. assert ( nh > 0.0 );
  49. nw = nh * src.width() / src.height();
  50. }
  51. if ( nh <= 0 ) {
  52. nh = nw * src.height() / src.width();
  53. }
  54. dst.resize(nw, nh);
  55. NICE::scale ( src, &dst );
  56. }