Esempio n. 1
0
static double ssim(float *x, float *y, int n)
{
	double mx, my, sx, sy, sxy = 0;
	meanvar(&mx, &sx, x, n);
	meanvar(&my, &sy, y, n);
	for (int i = 0; i < n; i++)
		sxy += (x[i] - mx)*(y[i] - my);
	sxy /= n - 1;
	double Lx = dynamic_range(x, n);
	double Ly = dynamic_range(x, n);
	double L = (Lx + Ly)/2;
	double C1 = SSIM_K1 * L;
	double C2 = SSIM_K2 * L;
	C1 *= C1;
	C2 *= C2;
	double r = (2*mx*my + C1) * (2*sxy + C2);
	r /= (mx*mx + my*my + C1) * (sx + sx + C2);
	return r;
}
void print_parameter_settings ()
{
  fprintf (stderr, "\tImage size       = %i %i\n", cvts.xmax, cvts.ymax);
  fprintf (stderr, "\tLowest scale     = %i pixels\t\t(-low <integer>)\n", scale_low);
  fprintf (stderr, "\tHighest scale    = %i pixels\t\t(-high <integer>)\n", scale_high);
  fprintf (stderr, "\tNumber of scales = %i\t\t\t(-num <integer>)\n", range);
  fprintf (stderr, "\tScale spacing    = %f\n", S_I(1) / S_I(0));
  fprintf (stderr, "\tKey value        = %f\t\t(-key <float>)\n", key);
  fprintf (stderr, "\tWhite value      = %f\t\t(-white <float>)\n", white);
  fprintf (stderr, "\tPhi              = %f\t\t(-phi <float>)\n", phi);
  fprintf (stderr, "\tThreshold        = %f\t\t(-threshold <float>)\n", threshold);
  dynamic_range ();
}
Esempio n. 3
0
static double psnr(float *x, float *y, int n)
{
	return 20 * log10(dynamic_range(x, n)/root_mean_square_error(x, y, n));
}
Esempio n. 4
0
bool mspectrumcondition::condition(mspectrum &_s)
{
/*
 * bail out if conditioning has been turned off
 */
	if(m_bUsePhosphoDetection)	{
		if(!find_loss(_s,98.0,3.0))	{
			return false;
		}
	}
	_s.m_vMINeutral.clear();
	sort(_s.m_vMI.begin(),_s.m_vMI.end(),lessThanMImz);
	if(_s.m_dMH < 1.0 && !_s.m_vMI.empty())	{
		m_bCharge = true;
		if(_s.m_fZ == 2.0)	{
			_s.m_dMH = _s.m_vMI[_s.m_vMI.size()-1].m_fM*1.2;
		}
		else if(_s.m_fZ == 3.0)	{
			_s.m_dMH = _s.m_vMI[_s.m_vMI.size()-1].m_fM*1.7;
		}
	}
	if(_s.m_vdStats.size() == 0)	{
		vector<mi>::iterator itMI = _s.m_vMI.begin();
		vector<mi>::iterator itEnd = _s.m_vMI.end();
		double dSum = 0.0;
		double dMax = 0.0;
		while(itMI != itEnd)	{
			if(dMax < itMI->m_fI)	{
				dMax = itMI->m_fI;
			}
			dSum += itMI->m_fI;
			itMI++;
		}
		_s.m_vdStats.push_back(dSum);
		_s.m_vdStats.push_back(dMax);
		_s.m_vdStats.push_back(m_fFactor);
	}
	if(_s.m_fZ > m_fMaxZ)	{
		return false;
	}
	if(!m_bCondition)	{
		return true;
	}
/*
 * check the parent ion charge and return false if it is too large
 */
	if(m_bUseNoiseSuppression)	{
		/*
		 * check the parent ion mass against the minimum mass allowed (about 600.0 is usually safe)
		*/
		if(m_bUseMinMass)	{
			if(_s.m_dMH < m_fMinMass)
				return false;
		}
		if(m_bUseChargeSuppression)	{
			if((long)(_s.m_fZ+0.5) > m_lMaxCharge)	{
				return false;
			}
		}
	}
	size_t tSize = _s.m_vMI.size();
	size_t a = 0;
	float fMaxI = 0;
/*
 * this method doesn't really remove isotopes: it cleans up multiple intensities within one Dalton
 * of each other.
 */
//	sort(_s.m_vMI.begin(),_s.m_vMI.end(),lessThanMImz);
	if(m_bUseIsotopes)	{
		remove_isotopes(_s);
	}
/*
 * remove ions near the parent ion m/z
 */
	if(m_bUseParent)	{
		remove_parent(_s);
	}
/*
 * remove low mass immonium ions prior to normalization
 */
	if(m_bUseLowestMass)	{
		remove_low_masses(_s);
	}
/*
 * normalize the spectrum 
 */
	vector<mi>::iterator itMI = _s.m_vMI.begin();
	vector<mi>::iterator itEnd = _s.m_vMI.end();
	double dSum = 0.0;
	double dMax = 0.0;
	while(itMI != itEnd)	{
		if(dMax < itMI->m_fI)	{
			dMax = itMI->m_fI;
		}
		dSum += itMI->m_fI;
		itMI++;
	}
	_s.m_vdStats.clear();
	_s.m_vdStats.push_back(dSum);
	_s.m_vdStats.push_back(dMax);
	_s.m_vdStats.push_back(m_fFactor);
	if(m_bUseDynamicRange)	{
		dynamic_range(_s);
	}
	if(m_bUseNeutralLoss)	{
		remove_neutral(_s);
	}
/*
* reject the spectrum if there aren't enough peaks 
*/
	if(m_bUseMinSize)	{
		if((long)_s.m_vMI.size() < m_lMinSize)
			return false;
	}
/*
 * check to see if the spectrum has the characteristics of noise 
 */
	if(m_bUseNoiseSuppression)	{
		if(is_noise(_s))	{
			return false;
		}
	}
/*
* retrieve the N most intense peaks
*/
	if(m_bUseIsotopes)	{
		clean_isotopes(_s);
	}
	if(m_bUseMaxPeaks)	{
		sort(_s.m_vMI.begin(),_s.m_vMI.end(),lessThanMI);
		remove_small(_s);
	}
	sort(_s.m_vMI.begin(),_s.m_vMI.end(),lessThanMImz);
	itMI = _s.m_vMI.begin();
	itEnd = _s.m_vMI.end();
	dSum = 0.0;
	dMax = 0.0;
	while(itMI != itEnd)	{
		if(dMax < itMI->m_fI)	{
			dMax = itMI->m_fI;
		}
		dSum += itMI->m_fI;
		itMI++;
	}
	_s.m_vdStats[0] = dSum*m_fFactor;
	_s.m_vdStats[1] = dMax*m_fFactor;
	_s.m_vdStats[2] = m_fFactor;
	return true;
}