40 #include <visp3/core/vpConfig.h>
42 #if defined(VISP_HAVE_CATCH2)
43 #define CATCH_CONFIG_RUNNER
46 #include <visp3/core/vpImageTools.h>
48 static unsigned int g_input_width = 7;
49 static unsigned int g_input_height = 5;
50 static unsigned int g_output_width = 4;
51 static unsigned int g_output_height = 3;
53 #ifdef ENABLE_VISP_NAMESPACE
56 TEST_CASE(
"Nearest neighbor interpolation",
"[image_resize]")
58 SECTION(
"unsigned char")
61 common_tools::fill(I);
63 common_tools::resizeRef(I, Iresize_ref, common_tools::g_nearest_neighbor);
68 std::cout <<
"I:\n" << I << std::endl;
69 std::cout <<
"Iresize_ref:\n" << Iresize_ref << std::endl;
70 std::cout <<
"Iresize:\n" << Iresize << std::endl;
72 CHECK((Iresize == Iresize_ref));
78 common_tools::fill(I);
80 common_tools::resizeRef(I, Iresize_ref, common_tools::g_nearest_neighbor);
85 std::cout <<
"I:\n" << I << std::endl;
86 std::cout <<
"Iresize_ref:\n" << Iresize_ref << std::endl;
87 std::cout <<
"Iresize:\n" << Iresize << std::endl;
89 CHECK((Iresize == Iresize_ref));
93 TEST_CASE(
"Bilinear interpolation",
"[image_resize]")
95 SECTION(
"unsigned char")
98 common_tools::fill(I);
100 common_tools::resizeRef(I, Iresize_ref, common_tools::g_bilinear);
105 std::cout <<
"I:\n" << I << std::endl;
106 std::cout <<
"Iresize_ref:\n" << Iresize_ref << std::endl;
107 std::cout <<
"Iresize:\n" << Iresize << std::endl;
109 CHECK((Iresize == Iresize_ref));
115 common_tools::fill(I);
117 common_tools::resizeRef(I, Iresize_ref, common_tools::g_bilinear);
122 std::cout <<
"I:\n" << I << std::endl;
123 std::cout <<
"Iresize_ref:\n" << Iresize_ref << std::endl;
124 std::cout <<
"Iresize:\n" << Iresize << std::endl;
126 const double max_pixel_error = 0.5;
128 CHECK(common_tools::almostEqual(Iresize, Iresize_ref, max_pixel_error, error));
129 std::cout <<
"Error: " << error << std::endl;
133 int main(
int argc,
char *argv[])
135 Catch::Session session;
138 using namespace Catch::clara;
139 auto cli = session.cli()
140 | Opt(g_input_width,
"g_input_width")
142 (
"Input image width.")
143 | Opt(g_input_height,
"g_input_height")
145 (
"Input image height.") |
146 Opt(g_output_width,
"g_output_width")
148 (
"Output image width.") |
149 Opt(g_output_height,
"g_output_height")
151 (
"Output image height.");
157 session.applyCommandLine(argc, argv);
159 std::cout <<
"Input image (wxh): " << g_input_width <<
"x" << g_input_height << std::endl;
160 std::cout <<
"Output image (wxh): " << g_output_width <<
"x" << g_output_height << std::endl;
162 int numFailed = session.run();
170 int main() {
return EXIT_SUCCESS; }