Skip to content

Commit

Permalink
Create simple test for Hessian detector
Browse files Browse the repository at this point in the history
This commit adds an s at the end of
function name to make it uniform with
another detector, and adds a simple
test for sanity check
  • Loading branch information
simmplecoder committed Aug 10, 2019
1 parent 914c0f1 commit 26acd98
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/boost/gil/image_processing/hessian.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace boost { namespace gil {
/// Weights change perception of surroinding pixels.
/// Additional filtering is strongly advised.
template <typename GradientView, typename Weights, typename OutputView>
inline void compute_hessian_response(
inline void compute_hessian_responses(
GradientView ddxx,
GradientView dxdy,
GradientView ddyy,
Expand Down
3 changes: 2 additions & 1 deletion test/core/image_processing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ endforeach()

foreach(_name
lanczos_scaling
simple_kernels)
simple_kernels
hessian)
set(_test t_core_image_processing_${_name})
set(_target test_core_image_processing_${_name})

Expand Down
1 change: 1 addition & 0 deletions test/core/image_processing/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ run threshold_truncate.cpp ;
run threshold_otsu.cpp ;
run lanczos_scaling.cpp ;
run simple_kernels.cpp ;
run hessian.cpp ;
72 changes: 72 additions & 0 deletions test/core/image_processing/hessian.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
//
// Copyright 2019 Olzhas Zhumabek <anonymous.from.applecity@gmail.com>
//
// Use, modification and distribution are subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include <boost/core/lightweight_test.hpp>
#include <boost/gil/image.hpp>
#include <boost/gil/image_view.hpp>
#include <boost/gil/image_processing/numeric.hpp>
#include <boost/gil/image_processing/hessian.hpp>

namespace gil = boost::gil;

bool are_equal(gil::gray32f_view_t expected, gil::gray32f_view_t actual) {
if (expected.dimensions() != actual.dimensions())
return false;

for (long int y = 0; y < expected.height(); ++y)
{
for (long int x = 0; x < expected.width(); ++x)
{
if (expected(x, y) != actual(x, y))
{
return false;
}
}
}

return true;
}

void test_blank_image()
{
const gil::point_t dimensions(20, 20);
gil::gray16_image_t dx(dimensions, gil::gray16_pixel_t(0), 0);
gil::gray16_image_t dy(dimensions, gil::gray16_pixel_t(0), 0);

gil::gray32f_image_t m11(dimensions);
gil::gray32f_image_t m12_21(dimensions);
gil::gray32f_image_t m22(dimensions);
gil::gray32f_image_t expected(dimensions, gil::gray32f_pixel_t(0), 0);
gil::compute_hessian_entries(
gil::view(dx),
gil::view(dy),
gil::view(m11),
gil::view(m12_21),
gil::view(m22)
);
BOOST_TEST(are_equal(gil::view(expected), gil::view(m11)));
BOOST_TEST(are_equal(gil::view(expected), gil::view(m12_21)));
BOOST_TEST(are_equal(gil::view(expected), gil::view(m22)));

gil::gray32f_image_t hessian_response(dimensions, gil::gray32f_pixel_t(0), 0);
gil::gray32f_image_t unnormalized_mean(gil::point_t(5, 5));
gil::generate_unnormalized_mean(gil::view(unnormalized_mean));
gil::compute_hessian_responses(
gil::view(m11),
gil::view(m12_21),
gil::view(m22),
gil::view(unnormalized_mean),
gil::view(hessian_response)
);
BOOST_TEST(are_equal(gil::view(expected), gil::view(hessian_response)));
}

int main(int argc, char* argv[])
{
test_blank_image();
return boost::report_errors();
}

0 comments on commit 26acd98

Please sign in to comment.