Boost GIL


numeric.hpp
1 //
2 // Copyright 2019 Olzhas Zhumabek <anonymous.from.applecity@gmail.com>
3 //
4 // Use, modification and distribution are subject to the Boost Software License,
5 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //
8 #ifndef BOOST_GIL_IMAGE_PROCESSING_NUMERIC_HPP
9 #define BOOST_GIL_IMAGE_PROCESSING_NUMERIC_HPP
10 
11 #include <boost/gil/detail/math.hpp>
12 #include <cmath>
13 
14 namespace boost { namespace gil {
15 
27 inline double normalized_sinc(double x)
28 {
29  return std::sin(x * boost::gil::pi) / (x * boost::gil::pi);
30 }
31 
39 inline double lanczos(double x, std::ptrdiff_t a)
40 {
41  // means == but <= avoids compiler warning
42  if (0 <= x && x <= 0)
43  return 1;
44 
45  if (-a < x && x < a)
46  return normalized_sinc(x) / normalized_sinc(x / static_cast<double>(a));
47 
48  return 0;
49 }
50 
51 }} // namespace boost::gil
52 
53 #endif
Definition: algorithm.hpp:30
double lanczos(double x, std::ptrdiff_t a)
Lanczos response at point xLanczos response is defined as: x == 0: 1 -a < x && x < a: 0 otherwise: no...
Definition: numeric.hpp:39