本文整理汇总了C++中vctDynamicVector::MaxElement方法的典型用法代码示例。如果您正苦于以下问题:C++ vctDynamicVector::MaxElement方法的具体用法?C++ vctDynamicVector::MaxElement怎么用?C++ vctDynamicVector::MaxElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vctDynamicVector
的用法示例。
在下文中一共展示了vctDynamicVector::MaxElement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ComputeEpsilon
double cisstAlgorithmICP_RobustICP::ComputeEpsilon(vctDynamicVector<double> &sampleDist)
{
unsigned int numSamps = sampleDist.size();
double minDist = sampleDist.MinElement();
double maxDist = sampleDist.MaxElement();
unsigned int numBins = 16;
double binWidth = (maxDist - minDist) / (double)numBins;
// build histogram of match distances
vctDynamicVector<unsigned int> bins(numBins, (unsigned int)0);
unsigned int sampleBin;
for (unsigned int i = 0; i < numSamps; i++)
{
if (sampleDist[i] == maxDist)
{ // handle max case
sampleBin = numBins - 1;
}
else
{
sampleBin = (unsigned int)floor((sampleDist[i] - minDist) / binWidth);
}
bins(sampleBin)++;
}
// find histogram peak
unsigned int peakBin = numBins; // initialize to invalid bin
unsigned int peakBinSize = 0;
for (unsigned int i = 0; i < numBins; i++)
{
if (bins(i) >= peakBinSize)
{
peakBin = i;
peakBinSize = bins(i);
}
}
// find valley following peak
// (valley bin must be <= 60% of peak bin size)
double valleyThresh = 0.6 * (double)peakBinSize;
unsigned int valleyBin = peakBin + 1;
for (unsigned int i = peakBin + 1; i < numBins; i++)
{
if ((double)bins(i) <= valleyThresh)
{
break;
}
valleyBin = i + 1;
}
// set epsilon to the smallest distance in the valley bin
double epsilon = minDist + valleyBin * binWidth;
//printHistogram(bins, peakBin, valleyBin, minDist, maxDist, binWidth);
return epsilon;
}