double PSNR::compute(cv::Mat orig[][3], cv::Mat processed[][3], int nFrames){ std::ofstream logfile; logfile.open ((logfile_path).c_str(), std::ios::out | std::ios::app ); //open in append mode double sum = 0; double tmp = 0; for(int i=0; i<nFrames;i++){ tmp = computeSingleFrame(orig[i][0], processed[i][0]); //[0].. only on luma channel sum += tmp; if(loglevel > 0){ //log by frame logfile << tmp << std::endl; } } logfile.close(); double psnr = sum/nFrames; addCalculation(psnr, nFrames); return psnr; }
// --- Parameterization ---------------------------------------------------- // bool MmffForceField::setup() { if(!m_parameters || m_parameters->fileName() != parameterFile()){ m_parameters = new MmffParameters; bool ok = m_parameters->read(parameterFile()); if(!ok){ setErrorString("Failed to load parameters: " + m_parameters->errorString()); delete m_parameters; m_parameters = 0; return false; } } const boost::shared_ptr<chemkit::Topology> &topology = this->topology(); if(!topology){ return false; } // bond strech calculations foreach(const chemkit::Topology::BondedInteraction &interaction, topology->bondedInteractions()){ size_t a = interaction[0]; size_t b = interaction[1]; addCalculation(new MmffBondStrechCalculation(a, b)); } // angle bend and strech bend calculations foreach(const chemkit::Topology::AngleInteraction &interaction, topology->angleInteractions()){ size_t a = interaction[0]; size_t b = interaction[1]; size_t c = interaction[2]; addCalculation(new MmffAngleBendCalculation(a, b, c)); addCalculation(new MmffStrechBendCalculation(a, b, c)); } // out of plane bending calculation (for each trigonal center) foreach(const chemkit::Topology::ImproperTorsionInteraction &interaction, topology->improperTorsionInteractions()){ size_t a = interaction[0]; size_t b = interaction[1]; size_t c = interaction[2]; size_t d = interaction[3]; addCalculation(new MmffOutOfPlaneBendingCalculation(a, b, c, d)); addCalculation(new MmffOutOfPlaneBendingCalculation(a, b, d, c)); addCalculation(new MmffOutOfPlaneBendingCalculation(c, b, d, a)); } // torsion calculations (for each dihedral) foreach(const chemkit::Topology::TorsionInteraction &interaction, topology->torsionInteractions()){ size_t a = interaction[0]; size_t b = interaction[1]; size_t c = interaction[2]; size_t d = interaction[3]; addCalculation(new MmffTorsionCalculation(a, b, c, d)); } // van der waals and electrostatic calculations foreach(const chemkit::Topology::NonbondedInteraction &interaction, topology->nonbondedInteractions()){ size_t a = interaction[0]; size_t b = interaction[1]; addCalculation(new MmffVanDerWaalsCalculation(a, b)); addCalculation(new MmffElectrostaticCalculation(a, b)); } bool ok = true; foreach(chemkit::ForceFieldCalculation *calculation, calculations()){ bool setup = static_cast<MmffCalculation *>(calculation)->setup(m_parameters); if(!setup){ ok = false; } setCalculationSetup(calculation, setup); }