Closed cgringmuth closed 1 year ago
sobel_scharr.cpp
Which is not correct in my opinion.
I have written a unit test which explains what I would expect from a 2 d convolution with sobel filter for the x direction.
void test_convolve_2d_with_sobel_x_filter() { const gil::uint8_t img[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; const gil::int16_t exp_output[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, -255, -255, 0, 0, 0, 0, 765, 765, 0, 0, -765, -765, 0, 0, 0, 0, 1020, 1020, 0, 0, -1020, -1020, 0, 0, 0, 0, 1020, 1020, 0, 0, -1020, -1020, 0, 0, 0, 0, 1020, 1020, 0, 0, -1020, -1020, 0, 0, 0, 0, 765, 765, 0, 0, -765, -765, 0, 0, 0, 0, 255, 255, 0, 0, -255, -255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; gil::gray16s_image_t img_gray_out(10, 13); auto src_view = gil::interleaved_view(10, 13, reinterpret_cast<const gil::gray8_pixel_t*>(img), 10); auto exp_out_view = gil::interleaved_view(10, 13, reinterpret_cast<const gil::gray16s_pixel_t*>(exp_output), 20); gil::detail::convolve_2d(src_view, gil::generate_dx_sobel(1), view(img_gray_out)); BOOST_TEST(gil::equal_pixels(exp_out_view, view(img_gray_out))); }
See unit test in Expected behavior.
Should be independent of environment. I didn't have any crash or something.
PS: I also don't know how to properly debug code in GIL properly. How I can see the content of an image in the debugger?
I think I fixed the issue already. Will create PR.
Actual behavior
sobel_scharr.cpp
with following image:Which is not correct in my opinion.
Expected behavior
I have written a unit test which explains what I would expect from a 2 d convolution with sobel filter for the x direction.
C++ Minimal Working Example
See unit test in Expected behavior.
Environment
Should be independent of environment. I didn't have any crash or something.
PS: I also don't know how to properly debug code in GIL properly. How I can see the content of an image in the debugger?