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


C++ PixelBox::toString方法代码示例

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


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

示例1: _calculateSplitY

int TileBoundsCalculator::_calculateSplitY(const PixelBox& b)
{
  double total = _sumPixels(b);

  double bottom = _sumPixels(b.getRowBox(b.minY));

  int best = (b.maxY + b.minY) / 2;
  double bestSum = numeric_limits<double>::max();

  double thisSlop = _slop + 1.0 / (double)(b.maxY - b.minY);

  if (b.getHeight() < 6)
  {
    throw HootException("The input box must be at least six pixels high.");
  }

  for (int r = b.minY + 2; r < b.maxY - 2; r++)
  {
    double rowSum = _sumPixels(b.getRowBox(r));
    double rowSumMin = _sumPixels(b.getRowBox(r), _min) + _sumPixels(b.getRowBox(r + 1), _min);
    bottom += rowSum;

    double slop = abs(0.5 - bottom / total);
    if ((slop < thisSlop) && rowSumMin < bestSum)
    {
      best = r;
      bestSum = rowSumMin;
    }
  }

  if (bestSum == numeric_limits<double>::max())
  {
    LOG_WARN("bestSum isn't valid. " << b.toString() << " total: " << total << " size: " <<
             b.maxY - b.minY);
  }

  return best;
}
开发者ID:drew-bower,项目名称:hootenanny,代码行数:38,代码来源:TileBoundsCalculator.cpp

示例2: _calculateSplitX

int TileBoundsCalculator::_calculateSplitX(PixelBox& b)
{
  double total = _sumPixels(b);

  double left = _sumPixels(b.getColumnBox(b.minX));

  int best = (b.maxX + b.minX) / 2;
  double bestSum = numeric_limits<double>::max();

  double thisSlop = _slop + 1.0 / (double)(b.maxX - b.minX);

  if (b.getWidth() < 6)
  {
    throw HootException("The input box must be at least six pixels high.");
  }

  for (int c = b.minX + 2; c < b.maxX - 2; c++)
  {
    double colSum = _sumPixels(b.getColumnBox(c));
    double colSumMin = _sumPixels(b.getColumnBox(c), _min) +
      _sumPixels(b.getColumnBox(c + 1), _min);
    left += colSum;

    double slop = abs(0.5 - left / total);
    if ((slop < thisSlop) && colSumMin < bestSum)
    {
      best = c;
      bestSum = colSumMin;
    }
  }

  if (bestSum == numeric_limits<double>::max())
  {
    LOG_WARN("bestSum isn't valid. " << b.toString());
  }

  return best;
}
开发者ID:drew-bower,项目名称:hootenanny,代码行数:38,代码来源:TileBoundsCalculator.cpp


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