Esempio n. 1
0
// ######################################################################
Image<float> downSizeClean(const Image<float>& src, const Dims& new_dims,
                           const int filterWidth)
{
GVX_TRACE(__PRETTY_FUNCTION__);

  if (src.getDims() == new_dims) return src;

  ASSERT(new_dims.isNonEmpty());
  ASSERT(filterWidth >= 1);

  Image<float> result = src;

  while (result.getWidth() > new_dims.w() * 2 &&
         result.getHeight() > new_dims.h() * 2)
    {
      if (filterWidth == 1)
        {
          result = decX(result);
          result = decY(result);
        }
      else if (filterWidth == 2)
        {
          result = quickLocalAvg2x2(result);
        }
      else
        {
          result = decX(lowPassX(filterWidth, result));
          result = decY(lowPassY(filterWidth, result));
        }
    }

  return rescaleBilinear(result, new_dims);
}