Skip to content

Commit

Permalink
improve test file formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
harshitpant1 committed Jun 23, 2021
1 parent 0bfb69d commit 76c6410
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 85 deletions.
6 changes: 4 additions & 2 deletions example/euclidean_distance_transform.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2021 Harsit Pant <[email protected]>
// Copyright 2021 Harshit Pant <[email protected]>
//
// Use, modification and distribution are subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Expand Down Expand Up @@ -76,6 +76,8 @@ int main(int argc, char* argv[])
}
else
{
std::cerr << "Incorrect options used.";
std::cerr << "This program fails to work with the set of arguments used. Please try again.";
}

return 0;
}
166 changes: 83 additions & 83 deletions test/core/image_processing/distance_transform.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2021 Harsit Pant <[email protected]>
// Copyright 2021 Harshit Pant <[email protected]>
//
// Use, modification and distribution are subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Expand Down Expand Up @@ -32,7 +32,7 @@ void check_for_negligible_varition(ImgView1 const& image_view1, ImgView2 const&
for (std::ptrdiff_t x = 0; x < image_view1.width(); ++x)
{
float variation = std::abs(image_view1(x, y)[0] - image_view2(x, y)[0]);
BOOST_TEST_LT(variation, 0.1);
BOOST_TEST_LT(variation, 0.001);
}
}
}
Expand All @@ -44,27 +44,27 @@ void test_manhattan_uint8_t_input_uint8_t_output_distance_from_off_pixels()
gil::gray8_image_t img_expected(7, 7);
gil::gray8_image_t img_out(7, 7);

//test values from wikipedia, in 8 bit binary form
// test values from wikipedia, in 8 bit binary form
std::vector<std::vector<int>> val_in
{
{0, 0, 0, 0, 0, 0,0},
{0,255,255,255,255,255,0},
{0,255,255,255,255,255,0},
{0,255,255,255,255,255,0},
{0,255,255,255,255,255,0},
{0,255,255,255,255,255,0},
{0, 0, 0, 0, 0, 0,0}
{0, 0, 0, 0, 0, 0, 0},
{0, 255, 255, 255, 255, 255, 0},
{0, 255, 255, 255, 255, 255, 0},
{0, 255, 255, 255, 255, 255, 0},
{0, 255, 255, 255, 255, 255, 0},
{0, 255, 255, 255, 255, 255, 0},
{0, 0, 0, 0, 0, 0, 0}
};

std::vector<std::vector<int>> val_exp
{
{0,0,0,0,0,0,0},
{0,1,1,1,1,1,0},
{0,1,2,2,2,1,0},
{0,1,2,3,2,1,0},
{0,1,2,2,2,1,0},
{0,1,1,1,1,1,0},
{0,0,0,0,0,0,0}
{0, 0, 0, 0, 0, 0, 0},
{0, 1, 1, 1, 1, 1, 0},
{0, 1, 2, 2, 2, 1, 0},
{0, 1, 2, 3, 2, 1, 0},
{0, 1, 2, 2, 2, 1, 0},
{0, 1, 1, 1, 1, 1, 0},
{0, 0, 0, 0, 0, 0, 0}
};

fill_image_view(val_in, view(img_in));
Expand Down Expand Up @@ -129,7 +129,7 @@ void test_chessboard_uint16_t_input_uint8_t_output_distance_from_on_pixels()
fill_image_view(val_exp_manhattan_five, view(img_expected));

gil::distance_transform(view(img_in), view(img_out), gil::distance_from::on_pixels,
gil::distance_type::manhattan, gil::mask_size::five);
gil::distance_type::manhattan, gil::mask_size::five);

BOOST_TEST(equal_pixels(const_view(img_out), const_view(img_expected)));

Expand All @@ -147,7 +147,7 @@ void test_chessboard_uint16_t_input_uint8_t_output_distance_from_on_pixels()
fill_image_view(val_exp_euclidean_precise, view(img_expected_float32_t));

gil::distance_transform(view(img_in), view(img_out_float32_t), gil::distance_from::on_pixels,
gil::distance_type::precise_euclidean, gil::mask_size::not_applicable);
gil::distance_type::precise_euclidean, gil::mask_size::not_applicable);

BOOST_TEST(equal_pixels(const_view(img_out_float32_t), const_view(img_expected_float32_t)));
}
Expand Down Expand Up @@ -179,7 +179,7 @@ void test_euclidean_approx_and_manhattan_uint8_t_input_float32_t_output_distance

std::vector<std::vector<float>> val_exp1
{
{1.4f, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.4f},
{1.4f, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1.4f},
{ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{ 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1},
{ 1, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 1},
Expand Down Expand Up @@ -236,7 +236,7 @@ void test_all_uint8_t_input_float32_t_ouptut_distance_from_off_pixels()

std::vector<std::vector<int>> val_in
{
{ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255} ,
{ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
{ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 255, 255, 255, 255},
{ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
{ 255, 255, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255},
Expand All @@ -255,36 +255,36 @@ void test_all_uint8_t_input_float32_t_ouptut_distance_from_off_pixels()

std::vector<std::vector<float>> val_exp_precise
{
{3.6055512f, 3.1622777f, 3, 3.1622777f, 3.6055512f, 4.2426405f, 4.1231055f, 3.1622777f,
{3.6055512f, 3.1622777f, 3, 3.1622777f, 3.6055512f, 4.2426405f, 4.1231055f, 3.1622777f,
2.236068f, 1.4142135f, 1, 1.4142135f, 2.236068f, 3.1622777f, 4.1231055f},
{ 2.828427f, 2.236068f, 2, 2.236068f, 2.828427f, 3.6055512f, 4,
3, 2, 1, 0, 1, 2, 3, 4},
{ 2.236068f, 1.4142135f, 1, 1.4142135f, 2.236068f, 3.1622777f, 4.1231055f, 3.1622777f,
{ 2.828427f, 2.236068f, 2, 2.236068f, 2.828427f, 3.6055512f, 4,
3, 2, 1, 0, 1, 2, 3, 4},
{ 2.236068f, 1.4142135f, 1, 1.4142135f, 2.236068f, 3.1622777f, 4.1231055f, 3.1622777f,
2.236068f, 1.4142135f, 1, 1.4142135f, 2.236068f, 3.1622777f, 4.1231055f},
{ 2, 1, 0, 1, 2, 3, 4, 3.6055512f,
{ 2, 1, 0, 1, 2, 3, 4, 3.6055512f,
2.828427f, 2.236068f, 2, 2.236068f, 2.828427f, 3.6055512f, 4.472136f},
{ 2.236068f, 1.4142135f, 1, 1.4142135f, 2.236068f, 3.1622777f, 4.1231055f, 4.2426405f,
{ 2.236068f, 1.4142135f, 1, 1.4142135f, 2.236068f, 3.1622777f, 4.1231055f, 4.2426405f,
3.6055512f, 3.1622777f, 3, 3.1622777f, 3.6055512f, 4.2426405f, 5},
{ 2.828427f, 2.236068f, 2, 2.236068f, 2.828427f, 3.6055512f, 4.472136f, 5,
{ 2.828427f, 2.236068f, 2, 2.236068f, 2.828427f, 3.6055512f, 4.472136f, 5,
4.472136f, 4.1231055f, 4, 4.1231055f, 4.472136f, 5, 5.656854f},
{3.6055512f, 3.1622777f, 3, 3.1622777f, 3.6055512f, 4.2426405f, 5, 5.8309517f,
{3.6055512f, 3.1622777f, 3, 3.1622777f, 3.6055512f, 4.2426405f, 5, 5.8309517f,
5.3851647f, 5.0990195f, 5, 5.0990195f, 5.3851647f, 5.8309517f, 6.4031243f},
{ 4.472136f, 4.1231055f, 4, 4.1231055f, 4.472136f, 5, 5.656854f, 6.4031243f,
{ 4.472136f, 4.1231055f, 4, 4.1231055f, 4.472136f, 5, 5.656854f, 6.4031243f,
6.3245554f, 6.0827622f, 6, 6.0827622f, 6.3245554f, 6.7082043f, 7.0000005f},
{5.3851647f, 5.0990195f, 5, 5.0990195f, 5.3851647f, 5.8309517f, 6.4031243f, 7.0710683f,
{5.3851647f, 5.0990195f, 5, 5.0990195f, 5.3851647f, 5.8309517f, 6.4031243f, 7.0710683f,
7.2801094f, 7.0710683f, 7.0000005f, 6.7082043f, 6.3245554f, 6.0827622f, 6},
{6.3245554f, 6.0827622f, 6, 6.0827622f, 6.3245554f, 6.7082043f, 7.2111025f, 7.8102503f,
{6.3245554f, 6.0827622f, 6, 6.0827622f, 6.3245554f, 6.7082043f, 7.2111025f, 7.8102503f,
7.8102503f, 7.0710683f, 6.4031243f, 5.8309517f, 5.3851647f, 5.0990195f, 5},
{7.2801094f, 7.0710683f, 7.0000005f, 7.0710683f, 7.2801094f, 7.6157737f, 8.062258f, 8.062258f,
{7.2801094f, 7.0710683f, 7.0000005f, 7.0710683f, 7.2801094f, 7.6157737f, 8.062258f, 8.062258f,
7.2111025f, 6.4031243f, 5.656854f, 5, 4.472136f, 4.1231055f, 4},
{ 8.246211f, 8.062258f, 8, 8.062258f, 8.246211f, 8.5440035f, 8.5440035f, 7.6157737f,
{ 8.246211f, 8.062258f, 8, 8.062258f, 8.246211f, 8.5440035f, 8.5440035f, 7.6157737f,
6.7082043f, 5.8309517f, 5, 4.2426405f, 3.6055512f, 3.1622777f, 3},
{ 9.219544f, 9.055386f, 9, 9.055386f, 9.219544f, 9.219544f, 8.246211f, 7.2801094f,
{ 9.219544f, 9.055386f, 9, 9.055386f, 9.219544f, 9.219544f, 8.246211f, 7.2801094f,
6.3245554f, 5.3851647f, 4.472136f, 3.6055512f, 2.828427f, 2.236068f, 2},
{10.198039f, 10.049875f, 10, 10.049875f, 10.049875f, 9.055386f, 8.062258f, 7.0710683f,
{10.198039f, 10.049875f, 10, 10.049875f, 10.049875f, 9.055386f, 8.062258f, 7.0710683f,
6.0827622f, 5.0990195f, 4.1231055f, 3.1622777f, 2.236068f, 1.4142135f, 1},
{11.180341f, 11.045361f, 11, 11, 10, 9, 8, 7,
6, 5, 4, 3, 2, 1, 0}
{11.180341f, 11.045361f, 11, 11, 10, 9, 8, 7,
6, 5, 4, 3, 2, 1, 0}
};

fill_image_view(val_in, view(img_in));
Expand Down Expand Up @@ -352,51 +352,51 @@ void test_all_uint8_t_input_float32_t_ouptut_distance_from_off_pixels()

std::vector<std::vector<float>> val_exp_euclidean_five
{
{3.5969f, 3.1969f, 3, 3.1969f, 3.5969f, 4.2f,
4.1969f, 3.1969f, 2.1969f, 1.4f, 1, 1.4f,
2.1969f, 3.1969f, 4.1969f},
{ 2.8f, 2.1969f, 2, 2.1969f, 2.8f, 3.5969f,
4, 3, 2, 1, 0, 1,
2, 3, 4},
{2.1969f, 1.4f, 1, 1.4f, 2.1969f, 3.1969f,
4.1969f, 3.1969f, 2.1969f, 1.4f, 1, 1.4f,
2.1969f, 3.1969f, 4.1969f},
{ 2, 1, 0, 1, 2, 3,
4, 3.5969f, 2.8f, 2.1969f, 2, 2.1969f,
2.8f, 3.5969f, 4.3938f},
{2.1969f, 1.4f, 1, 1.4f, 2.1969f, 3.1969f,
4.1969f, 4.2f, 3.5969f, 3.1969f, 3, 3.1969f,
3.5969f, 4.2f, 4.9968996f},
{ 2.8f, 2.1969f, 2, 2.1969f, 2.8f, 3.5969f,
4.3938f, 4.9968996f, 4.3938f, 4.1969f, 4, 4.1969f,
4.3938f, 4.9968996f, 5.6f},
{3.5969f, 3.1969f, 3, 3.1969f, 3.5969f, 4.2f,
4.9968996f, 5.7938f, 5.3938f, 5.1969f, 5, 5.1969f,
5.3938f, 5.7938f, 6.3968997f},
{4.3938f, 4.1969f, 4, 4.1969f, 4.3938f, 4.9968996f,
5.6f, 6.3968997f, 6.3938f, 6.1969f, 6, 6.1969f,
6.3938f, 6.5906997f, 7},
{5.3938f, 5.1969f, 5, 5.1969f, 5.3938f, 5.7938f,
6.3968997f, 7, 7.3938f, 7.1969f, 7, 6.5906997f,
6.3938f, 6.1969f, 6},
{6.3938f, 6.1969f, 6, 6.1969f, 6.3938f, 6.5906997f,
7.1937995f, 7.7969f, 7.7969f, 7, 6.3968997f, 5.7938f,
5.3938f, 5.1969f, 5},
{7.3938f, 7.1969f, 7, 7.1969f, 7.3938f, 7.5906997f,
7.9907f, 7.9907f, 7.1937995f, 6.3968997f, 5.6f, 4.9968996f,
4.3938f, 4.1969f, 4},
{8.3938f, 8.196899f, 8, 8.196899f, 8.3938f, 8.5907f,
8.5907f, 7.5906997f, 6.5906997f, 5.7938f, 4.9968996f, 4.2f,
3.5969f, 3.1969f, 3},
{9.3938f, 9.196899f, 9, 9.196899f, 9.3938f, 9.3938f,
8.3938f, 7.3938f, 6.3938f, 5.3938f, 4.3938f, 3.5969f,
2.8f, 2.1969f, 2},
{10.393799f, 10.196899f, 10, 10.196899f, 10.196899f, 9.196899f,
8.196899f, 7.1969f, 6.1969f, 5.1969f, 4.1969f, 3.1969f,
2.1969f, 1.4f, 1},
{11.393799f, 11.196899f, 11, 11, 10, 9,
8, 7, 6, 5, 4, 3,
2, 1, 0}
{ 3.5969f, 3.1969f, 3, 3.1969f, 3.5969f, 4.2f,
4.1969f, 3.1969f, 2.1969f, 1.4f, 1, 1.4f,
2.1969f, 3.1969f, 4.1969f},
{ 2.8f, 2.1969f, 2, 2.1969f, 2.8f, 3.5969f,
4, 3, 2, 1, 0, 1,
2, 3, 4},
{ 2.1969f, 1.4f, 1, 1.4f, 2.1969f, 3.1969f,
4.1969f, 3.1969f, 2.1969f, 1.4f, 1, 1.4f,
2.1969f, 3.1969f, 4.1969f},
{ 2, 1, 0, 1, 2, 3,
4, 3.5969f, 2.8f, 2.1969f, 2, 2.1969f,
2.8f, 3.5969f, 4.3938f},
{ 2.1969f, 1.4f, 1, 1.4f, 2.1969f, 3.1969f,
4.1969f, 4.2f, 3.5969f, 3.1969f, 3, 3.1969f,
3.5969f, 4.2f, 4.9968996f},
{ 2.8f, 2.1969f, 2, 2.1969f, 2.8f, 3.5969f,
4.3938f, 4.9968996f, 4.3938f, 4.1969f, 4, 4.1969f,
4.3938f, 4.9968996f, 5.6f},
{ 3.5969f, 3.1969f, 3, 3.1969f, 3.5969f, 4.2f,
4.9968996f, 5.7938f, 5.3938f, 5.1969f, 5, 5.1969f,
5.3938f, 5.7938f, 6.3968997f},
{ 4.3938f, 4.1969f, 4, 4.1969f, 4.3938f, 4.9968996f,
5.6f, 6.3968997f, 6.3938f, 6.1969f, 6, 6.1969f,
6.3938f, 6.5906997f, 7},
{ 5.3938f, 5.1969f, 5, 5.1969f, 5.3938f, 5.7938f,
6.3968997f, 7, 7.3938f, 7.1969f, 7, 6.5906997f,
6.3938f, 6.1969f, 6},
{ 6.3938f, 6.1969f, 6, 6.1969f, 6.3938f, 6.5906997f,
7.1937995f, 7.7969f, 7.7969f, 7, 6.3968997f, 5.7938f,
5.3938f, 5.1969f, 5},
{ 7.3938f, 7.1969f, 7, 7.1969f, 7.3938f, 7.5906997f,
7.9907f, 7.9907f, 7.1937995f, 6.3968997f, 5.6f, 4.9968996f,
4.3938f, 4.1969f, 4},
{ 8.3938f, 8.196899f, 8, 8.196899f, 8.3938f, 8.5907f,
8.5907f, 7.5906997f, 6.5906997f, 5.7938f, 4.9968996f, 4.2f,
3.5969f, 3.1969f, 3},
{ 9.3938f, 9.196899f, 9, 9.196899f, 9.3938f, 9.3938f,
8.3938f, 7.3938f, 6.3938f, 5.3938f, 4.3938f, 3.5969f,
2.8f, 2.1969f, 2},
{10.393799f, 10.196899f, 10, 10.196899f, 10.196899f, 9.196899f,
8.196899f, 7.1969f, 6.1969f, 5.1969f, 4.1969f, 3.1969f,
2.1969f, 1.4f, 1},
{11.393799f, 11.196899f, 11, 11, 10, 9,
8, 7, 6, 5, 4, 3,
2, 1, 0}
};

fill_image_view(val_in, view(img_in));
Expand Down

0 comments on commit 76c6410

Please sign in to comment.