Mercurial > hg > orthanc
changeset 3431:e0841192d7d0
improved FillPolygon
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Mon, 17 Jun 2019 23:36:37 +0200 |
parents | 4c45e018bd3d |
children | 297ad330900c |
files | Core/Images/ImageProcessing.cpp UnitTestsSources/ImageProcessingTests.cpp |
diffstat | 2 files changed, 12 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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<int32_t> nodeX; nodeX.resize(cpSize); int nodes, pixelX, pixelY, i, j, swap ;
--- 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)); }