/** 
* @file Conversions.cpp
* @brief boring conversions
* @author Erik Rodner
* @date 02/19/2008

*/
#include "core/image/ImageT.h"
#include "core/vector/VectorT.h"
#include "core/vector/MatrixT.h"

#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 );
}
