42 #include <visp3/core/vpConfig.h>
44 #if defined(VISP_HAVE_CATCH2)
45 #define CATCH_CONFIG_RUNNER
48 #include <visp3/core/vpImageTools.h>
50 static unsigned int g_input_width = 7;
51 static unsigned int g_input_height = 5;
52 static unsigned int g_output_width = 4;
53 static unsigned int g_output_height = 3;
55 TEST_CASE(
"Nearest neighbor interpolation",
"[image_resize]")
57 SECTION(
"unsigned char")
60 common_tools::fill(I);
62 common_tools::resizeRef(I, Iresize_ref, common_tools::g_nearest_neighbor);
67 std::cout <<
"I:\n" << I << std::endl;
68 std::cout <<
"Iresize_ref:\n" << Iresize_ref << std::endl;
69 std::cout <<
"Iresize:\n" << Iresize << std::endl;
71 CHECK((Iresize == Iresize_ref));
77 common_tools::fill(I);
79 common_tools::resizeRef(I, Iresize_ref, common_tools::g_nearest_neighbor);
84 std::cout <<
"I:\n" << I << std::endl;
85 std::cout <<
"Iresize_ref:\n" << Iresize_ref << std::endl;
86 std::cout <<
"Iresize:\n" << Iresize << std::endl;
88 CHECK((Iresize == Iresize_ref));
92 TEST_CASE(
"Bilinear interpolation",
"[image_resize]")
94 SECTION(
"unsigned char")
97 common_tools::fill(I);
99 common_tools::resizeRef(I, Iresize_ref, common_tools::g_bilinear);
104 std::cout <<
"I:\n" << I << std::endl;
105 std::cout <<
"Iresize_ref:\n" << Iresize_ref << std::endl;
106 std::cout <<
"Iresize:\n" << Iresize << std::endl;
108 CHECK((Iresize == Iresize_ref));
114 common_tools::fill(I);
116 common_tools::resizeRef(I, Iresize_ref, common_tools::g_bilinear);
121 std::cout <<
"I:\n" << I << std::endl;
122 std::cout <<
"Iresize_ref:\n" << Iresize_ref << std::endl;
123 std::cout <<
"Iresize:\n" << Iresize << std::endl;
125 const double max_pixel_error = 0.5;
127 CHECK(common_tools::almostEqual(Iresize, Iresize_ref, max_pixel_error, error));
128 std::cout <<
"Error: " << error << std::endl;
132 int main(
int argc,
char *argv[])
134 Catch::Session session;
137 using namespace Catch::clara;
138 auto cli = session.cli()
139 | Opt(g_input_width,
"g_input_width")
141 (
"Input image width.")
142 | Opt(g_input_height,
"g_input_height")
144 (
"Input image height.") |
145 Opt(g_output_width,
"g_output_width")
147 (
"Output image width.") |
148 Opt(g_output_height,
"g_output_height")
150 (
"Output image height.");
156 session.applyCommandLine(argc, argv);
158 std::cout <<
"Input image (wxh): " << g_input_width <<
"x" << g_input_height << std::endl;
159 std::cout <<
"Output image (wxh): " << g_output_width <<
"x" << g_output_height << std::endl;
161 int numFailed = session.run();
169 int main() {
return EXIT_SUCCESS; }