12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- /**
- * @file Conversions.cpp
- * @brief boring conversions
- * @author Erik Rodner
- * @date 02/19/2008
- */
- #ifdef NOVISUAL
- #include <vislearning/nice_nonvis.h>
- #else
- #include <vislearning/nice.h>
- #endif
- #include <iostream>
- #include <assert.h>
- #include "vislearning/baselib/Conversions.h"
- using namespace OBJREC;
- using namespace std;
- using namespace NICE;
- Conversions::Conversions()
- {
- }
- Conversions::~Conversions()
- {
- }
- vector<double> Conversions::stl_vector ( const NICE::Vector & x )
- {
- vector<double> y;
- for ( size_t i = 0 ; i < x.size(); i++ )
- y.push_back(x[i]);
- return y;
- }
-
- void Conversions::resizeImage ( const NICE::Image & src, NICE::Image & dst, int newWidth, int newHeight )
- {
- int nw = newWidth;
- int nh = newHeight;
-
- if ( nw <= 0 ) {
- assert ( nh > 0.0 );
- nw = nh * src.width() / src.height();
- }
- if ( nh <= 0 ) {
- nh = nw * src.height() / src.width();
- }
- dst.resize(nw, nh);
- NICE::scale ( src, &dst );
- }
- void Conversions::resizeImage ( const NICE::ColorImage & src, NICE::ColorImage & dst, int newWidth, int newHeight )
- {
- int nw = newWidth;
- int nh = newHeight;
-
- if ( nw <= 0 ) {
- assert ( nh > 0.0 );
- nw = nh * src.width() / src.height();
- }
- if ( nh <= 0 ) {
- nh = nw * src.height() / src.width();
- }
-
- dst.resize(nw, nh);
- NICE::scale ( src, &dst );
- }
|