Skip to content

Commit f122dc5

Browse files
committed
image: add test for image_erosion
1 parent dd49534 commit f122dc5

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/test-image.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,34 @@ VISP_TEST(image_blur) {
252252
CHECK_IMAGES_EQUAL(output, expected);
253253
}
254254

255+
VISP_TEST(image_erosion) {
256+
constexpr i32x2 extent{6, 6};
257+
std::array<float, extent[0] * extent[1]> input_data = {
258+
0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, //
259+
0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, //
260+
0.8f, 0.8f, 1.0f, 0.5f, 0.0f, 1.0f, //
261+
0.8f, 0.8f, 1.0f, 0.5f, 0.5f, 0.0f, //
262+
0.8f, 1.0f, 1.0f, 0.5f, 0.5f, 0.0f, //
263+
0.0f, 1.0f, 1.0f, 0.2f, 0.5f, 0.0f //
264+
};
265+
std::array<float, extent[0] * extent[1]> expected_data = {
266+
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, //
267+
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, //
268+
0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, //
269+
0.8f, 0.8f, 0.5f, 0.0f, 0.0f, 0.0f, //
270+
0.0f, 0.0f, 0.2f, 0.2f, 0.0f, 0.0f, //
271+
0.0f, 0.0f, 0.2f, 0.2f, 0.0f, 0.0f //
272+
};
273+
std::array<float, extent[0] * extent[1]> output_data{};
274+
275+
auto input = image_view(extent, input_data);
276+
auto output = image_span(extent, output_data);
277+
image_erosion(input, output, 1);
278+
279+
auto expected = image_view(extent, expected_data);
280+
CHECK_IMAGES_EQUAL(output, expected);
281+
}
282+
255283
VISP_TEST(tile_merge) {
256284
std::array<std::array<f32x3, 5 * 5>, 4> tiles;
257285
for (int t = 0; t < 4; ++t) {

0 commit comments

Comments
 (0)