-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create simple test for Hessian detector
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
1 parent
914c0f1
commit 26acd98
Showing
4 changed files
with
76 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |