]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/gil/test/core/image_processing/hessian.cpp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / boost / libs / gil / test / core / image_processing / hessian.cpp
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 #include <boost/gil/image.hpp>
9 #include <boost/gil/image_view.hpp>
10 #include <boost/gil/image_processing/numeric.hpp>
11 #include <boost/gil/image_processing/hessian.hpp>
12
13 #include <boost/core/lightweight_test.hpp>
14
15 namespace gil = boost::gil;
16
17 bool are_equal(gil::gray32f_view_t expected, gil::gray32f_view_t actual) {
18 if (expected.dimensions() != actual.dimensions())
19 return false;
20
21 for (long int y = 0; y < expected.height(); ++y)
22 {
23 for (long int x = 0; x < expected.width(); ++x)
24 {
25 if (expected(x, y) != actual(x, y))
26 {
27 return false;
28 }
29 }
30 }
31
32 return true;
33 }
34
35 void test_blank_image()
36 {
37 const gil::point_t dimensions(20, 20);
38 gil::gray16s_image_t dx(dimensions, gil::gray16s_pixel_t(0), 0);
39 gil::gray16s_image_t dy(dimensions, gil::gray16s_pixel_t(0), 0);
40
41 gil::gray32f_image_t m11(dimensions);
42 gil::gray32f_image_t m12_21(dimensions);
43 gil::gray32f_image_t m22(dimensions);
44 gil::gray32f_image_t expected(dimensions, gil::gray32f_pixel_t(0), 0);
45 gil::compute_hessian_entries(
46 gil::view(dx),
47 gil::view(dy),
48 gil::view(m11),
49 gil::view(m12_21),
50 gil::view(m22)
51 );
52 BOOST_TEST(are_equal(gil::view(expected), gil::view(m11)));
53 BOOST_TEST(are_equal(gil::view(expected), gil::view(m12_21)));
54 BOOST_TEST(are_equal(gil::view(expected), gil::view(m22)));
55
56 gil::gray32f_image_t hessian_response(dimensions, gil::gray32f_pixel_t(0), 0);
57 auto unnormalized_mean = gil::generate_unnormalized_mean(5);
58 gil::compute_hessian_responses(
59 gil::view(m11),
60 gil::view(m12_21),
61 gil::view(m22),
62 unnormalized_mean,
63 gil::view(hessian_response)
64 );
65 BOOST_TEST(are_equal(gil::view(expected), gil::view(hessian_response)));
66 }
67
68 int main(int argc, char* argv[])
69 {
70 test_blank_image();
71 return boost::report_errors();
72 }