]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/gil/test/core/image_processing/lanczos_scaling.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / gil / test / core / image_processing / lanczos_scaling.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_processing/scaling.hpp>
9 #include <boost/gil/image.hpp>
10
11 #include <boost/core/lightweight_test.hpp>
12
13
14 #include <iostream>
15
16 namespace gil = boost::gil;
17
18 bool are_equal(gil::rgb8_view_t expected, gil::rgb8_view_t actual) {
19 if (expected.dimensions() != actual.dimensions())
20 return false;
21
22 for (long int y = 0; y < expected.height(); ++y)
23 {
24 for (long int x = 0; x < expected.width(); ++x)
25 {
26 if (expected(x, y) != actual(x, y))
27 {
28 return false;
29 }
30 }
31 }
32
33 return true;
34 }
35
36 void test_lanczos_black_image()
37 {
38
39 const gil::point_t input_dimensions(20, 20);
40 const gil::point_t output_dimensions(input_dimensions.x / 2, input_dimensions.y / 2);
41 gil::rgb8_image_t image(input_dimensions, gil::rgb8_pixel_t(0, 0, 0), 0);
42 // fill with values other than 0
43 gil::rgb8_image_t output_image(
44 output_dimensions,
45 gil::rgb8_pixel_t(100, 100, 100),
46 0
47 );
48 gil::rgb8_image_t expected(
49 output_dimensions,
50 gil::rgb8_pixel_t(0, 0, 0),
51 0
52 );
53
54 auto view = gil::view(image);
55 auto output_view = gil::view(output_image);
56 auto expected_view = gil::view(expected);
57 gil::scale_lanczos(view, output_view, 5);
58 BOOST_TEST(are_equal(expected_view,output_view));
59 }
60
61 void test_lanczos_response_on_zero()
62 {
63 //random value for a
64 BOOST_TEST(gil::lanczos(0, 2) == 1);
65 }
66
67 int main()
68 {
69 test_lanczos_black_image();
70 test_lanczos_response_on_zero();
71 return boost::report_errors();
72 }