Skip to content

Commit

Permalink
Adjust line related tests
Browse files Browse the repository at this point in the history
  • Loading branch information
simmplecoder committed Aug 30, 2020
1 parent 048144e commit e12a64a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions test/core/image_processing/hough_line_transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ const std::ptrdiff_t width = 64;

void translate(std::vector<gil::point_t>& points, std::ptrdiff_t intercept)
{
std::transform(points.begin(), points.end(), points.begin(), [intercept](gil::point_t point) {
return gil::point_t{point.x, point.y + intercept};
});
std::transform(points.begin(), points.end(), points.begin(),
[intercept](gil::point_t point)
{
return gil::point_t{point.x, point.y + intercept};
});
}

void hough_line_test(std::ptrdiff_t height, std::ptrdiff_t intercept)
Expand All @@ -38,7 +40,7 @@ void hough_line_test(std::ptrdiff_t height, std::ptrdiff_t intercept)
gil::gray8_image_t image(width, width, gil::gray8_pixel_t(0));
auto input = gil::view(image);
std::vector<gil::point_t> line_points(rasterizer.point_count(width, height));
rasterizer(width, height, line_points.begin());
rasterizer({0, 0}, {width - 1, height - 1}, line_points.begin());
translate(line_points, intercept);
for (const auto& p : line_points)
{
Expand Down Expand Up @@ -88,7 +90,7 @@ int main()
{
for (std::ptrdiff_t height = 1; height < width; ++height)
{
for (std::ptrdiff_t intercept = 1; intercept <= width - height - 1; ++intercept)
for (std::ptrdiff_t intercept = 1; intercept < width - height; ++intercept)
{
hough_line_test(height, intercept);
}
Expand Down
2 changes: 1 addition & 1 deletion test/core/rasterization/line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void test_bresenham_rasterizer_follows_equation(std::ptrdiff_t width, std::ptrdi
const auto rasterizer = gil::bresenham_line_rasterizer{};
const auto point_count = rasterizer.point_count(width, height);
std::vector<gil::point_t> bresenham_points(point_count);
rasterizer(width, height, bresenham_points.begin());
rasterizer({0, 0}, {width - 1, height - 1}, bresenham_points.begin());

for (std::ptrdiff_t i = 0; i < point_count; ++i)
{
Expand Down

0 comments on commit e12a64a

Please sign in to comment.