8 #ifndef BOOST_GIL_IMAGE_PROCESSING_HESSIAN_HPP
9 #define BOOST_GIL_IMAGE_PROCESSING_HESSIAN_HPP
11 #include <boost/gil/image_view.hpp>
12 #include <boost/gil/typedefs.hpp>
13 #include <boost/gil/image_processing/kernel.hpp>
16 namespace boost {
namespace gil {
26 template <
typename GradientView,
typename T,
typename Allocator,
typename OutputView>
27 inline void compute_hessian_responses(
31 const detail::kernel_2d<T, Allocator>& weights,
34 if (ddxx.dimensions() != ddyy.dimensions()
35 || ddyy.dimensions() != dxdy.dimensions()
36 || dxdy.dimensions() != dst.dimensions()
37 || weights.center_x() != weights.center_y())
39 throw std::invalid_argument(
"dimensions of views are not the same"
40 " or weights don't have equal width and height"
41 " or weights' dimensions are not odd");
44 using pixel_t =
typename std::remove_reference<decltype(std::declval<OutputView>()(0, 0))>::type;
46 using channel_t =
typename std::remove_reference
48 decltype(std::declval<pixel_t>().at(std::integral_constant<int, 0>{}))
52 auto center = weights.center_y();
53 for (
auto y = center; y < dst.height() - center; ++y)
55 for (
auto x = center; x < dst.width() - center; ++x)
57 auto ddxx_i = channel_t();
58 auto ddyy_i = channel_t();
59 auto dxdy_i = channel_t();
60 for (
typename OutputView::coord_t w_y = 0; w_y < static_cast<std::ptrdiff_t>(weights.size()); ++w_y)
62 for (
typename OutputView::coord_t w_x = 0; w_x < static_cast<std::ptrdiff_t>(weights.size()); ++w_x)
64 ddxx_i += ddxx(x + w_x - center, y + w_y - center)
65 .at(std::integral_constant<int, 0>{}) * weights.at(w_x, w_y);
66 ddyy_i += ddyy(x + w_x - center, y + w_y - center)
67 .at(std::integral_constant<int, 0>{}) * weights.at(w_x, w_y);
68 dxdy_i += dxdy(x + w_x - center, y + w_y - center)
69 .at(std::integral_constant<int, 0>{}) * weights.at(w_x, w_y);
72 auto determinant = ddxx_i * ddyy_i - dxdy_i * dxdy_i;
73 dst(x, y).at(std::integral_constant<int, 0>{}) = determinant;
defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
Definition: algorithm.hpp:36