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_median_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 183, 128, 181, 86, 34, 55, 134, 164, 15,
23 90, 59, 94, 158, 202, 0, 106, 120, 255,
24 65, 48, 4, 21, 21, 38, 50, 37, 228,
25 27, 245, 254, 164, 135, 192, 17, 241, 19,
26 56, 165, 253, 169, 24, 200, 249, 70, 199,
27 59, 84, 41, 96, 70, 58, 24, 20, 218,
28 235, 180, 12, 168, 224, 204, 166, 153, 1,
29 181, 213, 232, 178, 165, 253, 93, 214, 72,
30 171, 50, 20, 65, 67, 133, 249, 157, 105
33 std::uint8_t output[] =
35 128, 128, 128, 94, 55, 55, 120, 134, 120,
36 90, 90, 86, 86, 38, 50, 55, 120, 164,
37 65, 65, 94, 135, 135, 50, 50, 106, 228,
38 56, 65, 165, 135, 135, 50, 70, 70, 199,
39 59, 84, 165, 135, 135, 70, 70, 70, 199,
40 84, 84, 165, 96, 168, 166, 153, 153, 153,
41 181, 180, 168, 165, 168, 165, 153, 93, 72,
42 181, 180, 168, 165, 168, 166, 166, 153, 105,
43 171, 171, 65, 67, 133, 133, 157, 157, 105
46 BOOST_AUTO_TEST_SUITE(filter)
48 BOOST_AUTO_TEST_CASE(median_filter_with_kernel_size_3)
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::median_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);
62 BOOST_TEST(gil::equal_pixels(out_view, dst_view));
65 BOOST_AUTO_TEST_SUITE_END()