1 #ifndef BOOST_GIL_IMAGE_PROCESSING_HESSIAN_HPP     2 #define BOOST_GIL_IMAGE_PROCESSING_HESSIAN_HPP     4 #include <boost/gil/image_view.hpp>     5 #include <boost/gil/typedefs.hpp>     6 #include <boost/gil/extension/numeric/kernel.hpp>     9 namespace boost { 
namespace gil {
    19 template <
typename GradientView, 
typename T, 
typename Allocator, 
typename OutputView>
    20 inline void compute_hessian_responses(
    24     const detail::kernel_2d<T, Allocator>& weights,
    27     if (ddxx.dimensions() != ddyy.dimensions()
    28         || ddyy.dimensions() != dxdy.dimensions()
    29         || dxdy.dimensions() != dst.dimensions()
    30         || weights.center_x() != weights.center_y())
    32         throw std::invalid_argument(
"dimensions of views are not the same"    33             " or weights don't have equal width and height"    34             " or weights' dimensions are not odd");
    37     using pixel_t = 
typename std::remove_reference<decltype(std::declval<OutputView>()(0, 0))>::type;
    39     using channel_t = 
typename std::remove_reference
    41             decltype(std::declval<pixel_t>().at(std::integral_constant<int, 0>{}))
    45     auto center = weights.center_y();
    46     for (
auto y = center; y < dst.height() - center; ++y)
    48         for (
auto x = center; x < dst.width() - center; ++x)
    50             auto ddxx_i = channel_t();
    51             auto ddyy_i = channel_t();
    52             auto dxdy_i = channel_t();
    53             for (
typename OutputView::coord_t w_y = 0; w_y < weights.size(); ++w_y)
    55                 for (
typename OutputView::coord_t w_x = 0; w_x < weights.size(); ++w_x)
    57                     ddxx_i += ddxx(x + w_x - center, y + w_y - center)
    58                         .at(std::integral_constant<int, 0>{}) * weights.at(w_x, w_y);
    59                     ddyy_i += ddyy(x + w_x - center, y + w_y - center)
    60                         .at(std::integral_constant<int, 0>{}) * weights.at(w_x, w_y);
    61                     dxdy_i += dxdy(x + w_x - center, y + w_y - center)
    62                         .at(std::integral_constant<int, 0>{}) * weights.at(w_x, w_y);
    65             auto determinant = ddxx_i * ddyy_i - dxdy_i * dxdy_i;
    66             dst(x, y).at(std::integral_constant<int, 0>{}) = determinant;