math.hpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  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_DETAIL_MATH_HPP
  9. #define BOOST_GIL_IMAGE_PROCESSING_DETAIL_MATH_HPP
  10. #include <array>
  11. #include <boost/gil/extension/numeric/kernel.hpp>
  12. namespace boost { namespace gil {
  13. static constexpr double pi = 3.14159265358979323846;
  14. static constexpr std::array<float, 9> dx_sobel = {-1, 0, 1, -2, 0, 2, -1, 0, 1};
  15. static constexpr std::array<float, 9> dx_scharr = {-1, 0, 1, -1, 0, 1, -1, 0, 1};
  16. static constexpr std::array<float, 9> dy_sobel = {1, 2, 1, 0, 0, 0, -1, -2, -1};
  17. static constexpr std::array<float, 9> dy_scharr = {1, 1, 1, 0, 0, 0, -1, -1, -1};
  18. template <typename T, typename Allocator>
  19. inline detail::kernel_2d<T, Allocator> get_identity_kernel()
  20. {
  21. detail::kernel_2d<T, Allocator> kernel(1, 0, 0);
  22. kernel[0] = 1;
  23. return kernel;
  24. }
  25. }} // namespace boost::gil
  26. #endif