Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / gil / test / extension / numeric / convolve_cols.cpp
1 //
2 // Copyright 2019 Mateusz Loskot <mateusz at loskot dot net>
3 //
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
7 //
8 #include <boost/gil.hpp>
9 #include <boost/gil/extension/numeric/convolve.hpp>
10
11 #include <tuple>
12 #include <type_traits>
13
14 #define BOOST_TEST_MODULE test_ext_numeric_colvolve_cols
15 #include "unit_test.hpp"
16 #include "unit_test_utility.hpp"
17 #include "test_fixture.hpp"
18 #include "core/image/test_fixture.hpp"
19
20 namespace gil = boost::gil;
21 namespace fixture = boost::gil::test::fixture;
22
23 BOOST_AUTO_TEST_SUITE(convolve_cols)
24
25 BOOST_AUTO_TEST_CASE_TEMPLATE(image_1x1_kernel_1x1_identity, Image, fixture::image_types)
26 {
27     auto const img = fixture::create_image<Image>(1, 1, 7);
28     auto img_out = fixture::create_image<Image>(1, 1, 0);
29
30     using pixel_t = typename Image::value_type;
31     using channel_t = typename gil::channel_type<pixel_t>::type;
32     auto const kernel = fixture::create_kernel<channel_t>({1});
33     gil::convolve_cols<pixel_t>(const_view(img), kernel, view(img_out));
34
35     // 1x1 kernel reduces convolution to multiplication
36     BOOST_TEST(gil::const_view(img).front() == gil::const_view(img_out).front());
37 }
38
39 BOOST_AUTO_TEST_CASE_TEMPLATE(image_1x1_kernel_3x3_identity, Image, fixture::image_types)
40 {
41     auto const img = fixture::create_image<Image>(1, 1, 7);
42     auto img_out = fixture::create_image<Image>(1, 1, 0);
43
44     using pixel_t = typename Image::value_type;
45     using channel_t = typename gil::channel_type<pixel_t>::type;
46     auto const kernel = fixture::create_kernel<channel_t>({0, 0, 0, 0, 1, 0, 0, 0, 0});
47     gil::convolve_cols<pixel_t>(const_view(img), kernel, view(img_out));
48
49     BOOST_TEST(gil::const_view(img).front() == gil::const_view(img_out).front());
50 }
51
52 BOOST_AUTO_TEST_SUITE_END()