MCPcopy Create free account
hub / github.com/davisking/dlib / test_resize

Function test_resize

dlib/test/simd.cpp:41–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39 }
40
41 void test_resize()
42 {
43 // Bilinear interpolation must preserve a linear ramp. These dimensions
44 // exercise fractional coordinates, complete SIMD groups, and the scalar tail.
45 array2d<float> gray(17, 19), gray_out(12, 14);
46 array2d<rgb_pixel> rgb(17, 19), rgb_out(12, 14);
47 for (long r = 0; r < gray.nr(); ++r)
48 {
49 for (long c = 0; c < gray.nc(); ++c)
50 {
51 gray[r][c] = static_cast<float>(8*r + c);
52 rgb[r][c] = rgb_pixel(
53 static_cast<unsigned char>(4*r + 2*c),
54 static_cast<unsigned char>(2*r + 4*c),
55 static_cast<unsigned char>(3*r + c));
56 }
57 }
58 resize_image(gray, gray_out, interpolate_bilinear());
59 resize_image(rgb, rgb_out, interpolate_bilinear());
60 for (long r = 0; r < gray_out.nr(); ++r)
61 {
62 for (long c = 0; c < gray_out.nc(); ++c)
63 {
64 const double y = r*16.0/11;
65 const double x = c*18.0/13;
66 DLIB_TEST(std::abs(gray_out[r][c] - (8*y + x)) < 1e-4);
67 DLIB_TEST(std::abs(rgb_out[r][c].red - (4*y + 2*x)) <= 1);
68 DLIB_TEST(std::abs(rgb_out[r][c].green - (2*y + 4*x)) <= 1);
69 DLIB_TEST(std::abs(rgb_out[r][c].blue - (3*y + x)) <= 1);
70 }
71 }
72 }
73
74 class simd_tester : public tester
75 {

Callers 1

perform_testMethod · 0.85

Calls 6

rgb_pixelClass · 0.85
resize_imageFunction · 0.85
absFunction · 0.85
nrMethod · 0.45
ncMethod · 0.45

Tested by

no test coverage detected