]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/gil/test/extension/numeric/extend_boundary.cpp
2 // Copyright 2019 Pranam Lashkari <plashkari628@gmail.com>
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
8 #include <boost/gil.hpp>
9 #include <boost/gil/extension/numeric/algorithm.hpp>
10 #include <boost/gil/extension/numeric/convolve.hpp>
12 #include <boost/core/lightweight_test.hpp>
14 namespace gil
= boost::gil
;
18 1, 2, 3, 4, 5, 6, 7, 8, 9,
19 10, 0, 0, 0, 0, 0, 0, 0, 32,
20 11, 0, 255, 0, 0, 0, 255, 0, 31,
21 12, 0, 0, 255, 0, 255, 0, 0, 30,
22 13, 0, 0, 0, 255, 0, 0, 0, 29,
23 14, 0, 0, 255, 0, 255, 0, 0, 28,
24 15, 0, 255, 0, 0, 0, 255, 0, 27,
25 16, 0, 0, 0, 0, 0, 0, 0, 26,
26 17, 18, 19, 20, 21, 22, 23, 24, 25
29 std::uint8_t row_output_constant
[] =
31 1, 2, 3, 4, 5, 6, 7, 8, 9,
32 1, 2, 3, 4, 5, 6, 7, 8, 9,
33 1, 2, 3, 4, 5, 6, 7, 8, 9,
34 10, 0, 0, 0, 0, 0, 0, 0, 32,
35 11, 0, 255, 0, 0, 0, 255, 0, 31,
36 12, 0, 0, 255, 0, 255, 0, 0, 30,
37 13, 0, 0, 0, 255, 0, 0, 0, 29,
38 14, 0, 0, 255, 0, 255, 0, 0, 28,
39 15, 0, 255, 0, 0, 0, 255, 0, 27,
40 16, 0, 0, 0, 0, 0, 0, 0, 26,
41 17, 18, 19, 20, 21, 22, 23, 24, 25,
42 17, 18, 19, 20, 21, 22, 23, 24, 25,
43 17, 18, 19, 20, 21, 22, 23, 24, 25
46 std::uint8_t row_output_zero
[] =
48 0, 0, 0, 0, 0, 0, 0, 0, 0,
49 0, 0, 0, 0, 0, 0, 0, 0, 0,
50 0, 0, 0, 0, 0, 0, 0, 0, 0,
51 1, 2, 3, 4, 5, 6, 7, 8, 9,
52 10, 0, 0, 0, 0, 0, 0, 0, 32,
53 11, 0, 255, 0, 0, 0, 255, 0, 31,
54 12, 0, 0, 255, 0, 255, 0, 0, 30,
55 13, 0, 0, 0, 255, 0, 0, 0, 29,
56 14, 0, 0, 255, 0, 255, 0, 0, 28,
57 15, 0, 255, 0, 0, 0, 255, 0, 27,
58 16, 0, 0, 0, 0, 0, 0, 0, 26,
59 17, 18, 19, 20, 21, 22, 23, 24, 25,
60 0, 0, 0, 0, 0, 0, 0, 0, 0,
61 0, 0, 0, 0, 0, 0, 0, 0, 0,
62 0, 0, 0, 0, 0, 0, 0, 0, 0,
65 std::uint8_t col_output_constant
[] =
67 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9,
68 10, 10, 0, 0, 0, 0, 0, 0, 0, 32, 32,
69 11, 11, 0, 255, 0, 0, 0, 255, 0, 31, 31,
70 12, 12, 0, 0, 255, 0, 255, 0, 0, 30, 30,
71 13, 13, 0, 0, 0, 255, 0, 0, 0, 29, 29,
72 14, 14, 0, 0, 255, 0, 255, 0, 0, 28, 28,
73 15, 15, 0, 255, 0, 0, 0, 255, 0, 27, 27,
74 16, 16, 0, 0, 0, 0, 0, 0, 0, 26, 26,
75 17, 17, 18, 19, 20, 21, 22, 23, 24, 25, 25
78 std::uint8_t col_output_zero
[] =
80 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0,
81 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0,
82 0, 0, 11, 0, 255, 0, 0, 0, 255, 0, 31, 0, 0,
83 0, 0, 12, 0, 0, 255, 0, 255, 0, 0, 30, 0, 0,
84 0, 0, 13, 0, 0, 0, 255, 0, 0, 0, 29, 0, 0,
85 0, 0, 14, 0, 0, 255, 0, 255, 0, 0, 28, 0, 0,
86 0, 0, 15, 0, 255, 0, 0, 0, 255, 0, 27, 0, 0,
87 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 26, 0, 0,
88 0, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0
91 std::uint8_t boundary_output_constant
[] =
93 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9,
94 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9,
95 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9,
96 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 32, 32, 32,
97 11, 11, 11, 0, 255, 0, 0, 0, 255, 0, 31, 31, 31,
98 12, 12, 12, 0, 0, 255, 0, 255, 0, 0, 30, 30, 30,
99 13, 13, 13, 0, 0, 0, 255, 0, 0, 0, 29, 29, 29,
100 14, 14, 14, 0, 0, 255, 0, 255, 0, 0, 28, 28, 28,
101 15, 15, 15, 0, 255, 0, 0, 0, 255, 0, 27, 27, 27,
102 16, 16, 16, 0, 0, 0, 0, 0, 0, 0, 26, 26, 26,
103 17, 17, 17, 18, 19, 20, 21, 22, 23, 24, 25, 25, 25,
104 17, 17, 17, 18, 19, 20, 21, 22, 23, 24, 25, 25, 25,
105 17, 17, 17, 18, 19, 20, 21, 22, 23, 24, 25, 25, 25
108 std::uint8_t boundary_output_zero
[] =
110 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
111 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
112 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0,
113 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0,
114 0, 0, 11, 0, 255, 0, 0, 0, 255, 0, 31, 0, 0,
115 0, 0, 12, 0, 0, 255, 0, 255, 0, 0, 30, 0, 0,
116 0, 0, 13, 0, 0, 0, 255, 0, 0, 0, 29, 0, 0,
117 0, 0, 14, 0, 0, 255, 0, 255, 0, 0, 28, 0, 0,
118 0, 0, 15, 0, 255, 0, 0, 0, 255, 0, 27, 0, 0,
119 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 26, 0, 0,
120 0, 0, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0,
121 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
122 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
125 void test_extend_row_with_constant()
127 gil::gray8c_view_t src_view
=
128 gil::interleaved_view(9, 9, reinterpret_cast<const gil::gray8_pixel_t
*>(img
), 9);
130 gil::gray8c_view_t out_view
=
131 gil::interleaved_view(9, 13, reinterpret_cast<const gil::gray8_pixel_t
*>(row_output_constant
), 9);
133 auto output
= gil::extend_row(src_view
, 2, gil::boundary_option::extend_constant
);
135 BOOST_TEST(gil::equal_pixels(out_view
, gil::view(output
)));
138 void test_extend_row_with_zero()
140 gil::gray8c_view_t src_view
=
141 gil::interleaved_view(9, 9, reinterpret_cast<const gil::gray8_pixel_t
*>(img
), 9);
143 gil::gray8c_view_t out_view
=
144 gil::interleaved_view(9, 15, reinterpret_cast<const gil::gray8_pixel_t
*>(row_output_zero
), 9);
146 auto output
= gil::extend_row(src_view
, 3, gil::boundary_option::extend_zero
);
148 BOOST_TEST(gil::equal_pixels(out_view
, gil::view(output
)));
151 void test_extend_row_with_padded()
153 gil::gray8c_view_t src_view
=
154 gil::interleaved_view(9, 9, reinterpret_cast<const gil::gray8_pixel_t
*>(img
), 9);
156 auto src_sub_view
= gil::subimage_view(src_view
, 0, 1, 9, 7);
158 auto output
= gil::extend_row(src_sub_view
, 1, gil::boundary_option::extend_padded
);
160 BOOST_TEST(gil::equal_pixels(src_view
, gil::view(output
)));
163 void test_extend_col_with_constant()
165 gil::gray8c_view_t src_view
=
166 gil::interleaved_view(9, 9, reinterpret_cast<const gil::gray8_pixel_t
*>(img
), 9);
168 gil::gray8c_view_t out_view
=
169 gil::interleaved_view(11, 9, reinterpret_cast<const gil::gray8_pixel_t
*>(col_output_constant
), 11);
171 auto output
= gil::extend_col(src_view
, 1, gil::boundary_option::extend_constant
);
173 BOOST_TEST(gil::equal_pixels(out_view
, gil::view(output
)));
176 void test_extend_col_with_zero()
178 gil::gray8c_view_t src_view
=
179 gil::interleaved_view(9, 9, reinterpret_cast<const gil::gray8_pixel_t
*>(img
), 9);
181 gil::gray8c_view_t out_view
=
182 gil::interleaved_view(13, 9, reinterpret_cast<const gil::gray8_pixel_t
*>(col_output_zero
), 13);
184 auto output
= gil::extend_col(src_view
, 2, gil::boundary_option::extend_zero
);
186 BOOST_TEST(gil::equal_pixels(out_view
, gil::view(output
)));
189 void test_extend_col_with_padded()
191 gil::gray8c_view_t src_view
=
192 gil::interleaved_view(9, 9, reinterpret_cast<const gil::gray8_pixel_t
*>(img
), 9);
194 auto src_sub_view
= gil::subimage_view(src_view
, 1, 0, 7, 9);
196 auto output
= gil::extend_col(src_sub_view
, 1, gil::boundary_option::extend_padded
);
198 BOOST_TEST(gil::equal_pixels(src_view
, gil::view(output
)));
201 void test_extend_img_with_constant()
203 gil::gray8c_view_t src_view
=
204 gil::interleaved_view(9, 9, reinterpret_cast<const gil::gray8_pixel_t
*>(img
), 9);
206 gil::gray8c_view_t out_view
=
207 gil::interleaved_view(13, 13, reinterpret_cast<const gil::gray8_pixel_t
*>(boundary_output_constant
), 13);
209 auto output
= gil::extend_boundary(src_view
, 2, gil::boundary_option::extend_constant
);
211 BOOST_TEST(gil::equal_pixels(out_view
, gil::view(output
)));
214 void test_extend_img_with_zero()
216 gil::gray8c_view_t src_view
=
217 gil::interleaved_view(9, 9, reinterpret_cast<const gil::gray8_pixel_t
*>(img
), 9);
219 gil::gray8c_view_t out_view
=
220 gil::interleaved_view(13, 13, reinterpret_cast<const gil::gray8_pixel_t
*>(boundary_output_zero
), 13);
222 auto output
= gil::extend_boundary(src_view
, 2, gil::boundary_option::extend_zero
);
224 BOOST_TEST(gil::equal_pixels(out_view
, gil::view(output
)));
227 void test_extend_img_with_padded()
229 gil::gray8c_view_t src_view
=
230 gil::interleaved_view(9, 9, reinterpret_cast<const gil::gray8_pixel_t
*>(img
), 9);
232 auto src_sub_view
= gil::subimage_view(src_view
, 1, 1, 7, 7);
234 auto output
= gil::extend_boundary(src_sub_view
, 1, gil::boundary_option::extend_padded
);
236 BOOST_TEST(gil::equal_pixels(src_view
, gil::view(output
)));
241 test_extend_row_with_constant();
242 test_extend_row_with_zero();
243 test_extend_row_with_padded();
244 test_extend_col_with_constant();
245 test_extend_col_with_zero();
246 test_extend_col_with_padded();
247 test_extend_img_with_constant();
248 test_extend_img_with_zero();
249 test_extend_img_with_padded();
251 return ::boost::report_errors();