当前位置: 首页>>代码示例>>C++>>正文


C++ vector::pixelvalue方法代码示例

本文整理汇总了C++中typenamestd::vector::pixelvalue方法的典型用法代码示例。如果您正苦于以下问题:C++ vector::pixelvalue方法的具体用法?C++ vector::pixelvalue怎么用?C++ vector::pixelvalue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在typenamestd::vector的用法示例。


在下文中一共展示了vector::pixelvalue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: at

void	ImageMean<T>::compute(int x, int y, T darkvalue) {
	// if the dark value is invalid, then the computed value
	// is also invalid
	if (darkvalue != darkvalue) {
		image->pixel(x, y) = darkvalue;
		var->pixel(x, y) = darkvalue;
		return;
	}

	// perform mean (and possibly variance) computation in the
	// case where 
	//T	m;
	T	X = 0, X2 = 0;
	typename std::vector<PV>::const_iterator j;
	unsigned int	counter = 0;
	for (j = pvs.begin(); j != pvs.end(); j++) {
		T	v = j->pixelvalue(x, y);
		// skip this value if it is a NaN
		if (v != v)
			continue;
		if (v < darkvalue) {
			v = 0;
		} else {
			v = v - darkvalue;
		}
		X += v;
		if (enableVariance) {
			X2 += v * v;
		}
		counter++;
	}
	if (counter != pvs.size()) {
		debug(LOG_DEBUG, DEBUG_LOG, 0, "bad pixel values at (%d, %d): %d", x, y, counter);
	}
	T	EX = X / counter;
	T	EX2 = 0;
	if (enableVariance) {
		EX2 = X2 / counter;
	}

	// if we don't have the variance, we leave it at that
	if (!enableVariance) {
		image->pixel(x, y) = EX;
		return;
	}

	// if the variance is enabled, then we can do the computation
	// again, and ignore not only the bad values, but also the
	// ones that are more then 3 standard deviations away from 
	// the mean
	X = 0, X2 = 0;
	counter = 0;
	T	stddevk = k * sqrt(EX2 - EX * EX);
	if (stddevk < 1) {
		stddevk = std::numeric_limits<T>::infinity();
	}
	for (j = pvs.begin(); j != pvs.end(); j++) {
		T	v = j->pixelvalue(x, y);
		// skip NaNs
		if (v != v)
			continue;
		if (v < darkvalue) {
			v = 0;
		} else {
			v = v - darkvalue;
		}
		// skip values that are too far off
		if (fabs(v - EX) > stddevk) {
			continue;
		}
		X += v;
		X2 += v * v;
		counter++;
	}

	if (0 == counter) {
		image->pixel(x, y) = std::numeric_limits<T>::quiet_NaN();
		var->pixel(x, y) = std::numeric_limits<T>::quiet_NaN();
		return;
	}
	EX = X / counter;
	EX2 = X2 / counter;
	image->pixel(x, y) = EX;
	var->pixel(x, y) = EX2 - EX * EX;
}
开发者ID:AndreasFMueller,项目名称:AstroPhotography,代码行数:85,代码来源:CalibrationFactory.cpp


注:本文中的typenamestd::vector::pixelvalue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。