# HG changeset patch # User Alain Mazy # Date 1560807397 -7200 # Node ID e0841192d7d06cfd0b5623f6acd302180ca1bd76 # Parent 4c45e018bd3de3cfa21d6efc6734673aaaee4435 improved FillPolygon diff -r 4c45e018bd3d -r e0841192d7d0 Core/Images/ImageProcessing.cpp --- a/Core/Images/ImageProcessing.cpp Mon Jun 17 23:35:46 2019 +0200 +++ b/Core/Images/ImageProcessing.cpp Mon Jun 17 23:36:37 2019 +0200 @@ -1442,6 +1442,13 @@ cpy.push_back((double)points[i].GetY()); } + // Draw the lines segments + for (size_t i = 0; i < (points.size() -1); i++) + { + ImageProcessing::DrawLineSegment(image, points[i].GetX(), points[i].GetY(), points[i+1].GetX(), points[i+1].GetY(), value_); + } + ImageProcessing::DrawLineSegment(image, points[points.size() -1].GetX(), points[points.size() -1].GetY(), points[0].GetX(), points[0].GetY(), value_); + std::vector nodeX; nodeX.resize(cpSize); int nodes, pixelX, pixelY, i, j, swap ; diff -r 4c45e018bd3d -r e0841192d7d0 UnitTestsSources/ImageProcessingTests.cpp --- a/UnitTestsSources/ImageProcessingTests.cpp Mon Jun 17 23:35:46 2019 +0200 +++ b/UnitTestsSources/ImageProcessingTests.cpp Mon Jun 17 23:36:37 2019 +0200 @@ -220,9 +220,11 @@ ASSERT_FLOAT_EQ(128, TestFixture::ImageTraits::GetFloatPixel(image, 6, 6)); ASSERT_FLOAT_EQ(128, TestFixture::ImageTraits::GetFloatPixel(image, 6, 0)); - // inside polygon (note: we don't test too close from the edges since the current algo is taking some margin from the edges and might be improved in that sense) + ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 1, 1)); ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 1, 2)); + ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 1, 5)); ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 2, 4)); + ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 5, 5)); } TYPED_TEST(TestIntegerImageTraits, FillPolygonLargerThanImage) @@ -254,7 +256,6 @@ Orthanc::ImageProcessing::FillPolygon(image, points, 255); - // inside polygon (note: we don't test too close from the edges since the current algo is taking some margin from the edges and might be improved in that sense) - ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 1, 1)); - ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, image.GetWidth() - 2, image.GetHeight() - 2)); + ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 0, 0)); + ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, image.GetWidth() - 1, image.GetHeight() - 1)); }