2 // Copyright 2019 Miral Shah <miralshah2211@gmail.com>
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)
9 #define BOOST_TEST_MODULE test_image_processing_box_filter
10 #include "unit_test.hpp"
12 #include <boost/gil/image_view.hpp>
13 #include <boost/gil/algorithm.hpp>
14 #include <boost/gil/gray.hpp>
15 #include <boost/gil/image_processing/filter.hpp>
18 namespace gil = boost::gil;
22 0, 0, 0, 0, 0, 0, 0, 0, 0,
23 0, 0, 0, 0, 0, 0, 0, 0, 0,
24 0, 0, 255, 0, 0, 0, 255, 0, 0,
25 0, 0, 0, 255, 0, 255, 0, 0, 0,
26 0, 0, 0, 0, 255, 0, 0, 0, 0,
27 0, 0, 0, 255, 0, 255, 0, 0, 0,
28 0, 0, 255, 0, 0, 0, 255, 0, 0,
29 0, 0, 0, 0, 0, 0, 0, 0, 0,
30 0, 0, 0, 0, 0, 0, 0, 0, 0
33 std::uint8_t output[] =
35 0, 0, 0, 0, 0, 0, 0, 0, 0,
36 0, 28, 28, 28, 0, 28, 28, 28, 0,
37 0, 28, 56, 56, 56, 56, 56, 28, 0,
38 0, 28, 56, 85, 85, 85, 56, 28, 0,
39 0, 0, 56, 85, 141, 85, 56, 0, 0,
40 0, 28, 56, 85, 85, 85, 56, 28, 0,
41 0, 28, 56, 56, 56, 56, 56, 28, 0,
42 0, 28, 28, 28, 0, 28, 28, 28, 0,
43 0, 0, 0, 0, 0, 0, 0, 0, 0
46 BOOST_AUTO_TEST_SUITE(filter)
48 BOOST_AUTO_TEST_CASE(box_filter_with_default_parameters)
50 gil::gray8c_view_t src_view =
51 gil::interleaved_view(9, 9, reinterpret_cast<const gil::gray8_pixel_t*>(img), 9);
53 gil::image<gil::gray8_pixel_t> temp_img(src_view.width(), src_view.height());
54 typename gil::image<gil::gray8_pixel_t>::view_t temp_view = view(temp_img);
55 gil::gray8_view_t dst_view(temp_view);
57 gil::box_filter(src_view, dst_view, 3);
59 gil::gray8c_view_t out_view =
60 gil::interleaved_view(9, 9, reinterpret_cast<const gil::gray8_pixel_t*>(output), 9);
63 BOOST_TEST(gil::equal_pixels(out_view, dst_view));
66 BOOST_AUTO_TEST_SUITE_END()