comparison UnitTestsSources/ImageProcessingTests.cpp @ 3365:9345710bbf12

check limits in fillpolygon
author Alain Mazy <alain@mazy.be>
date Mon, 13 May 2019 14:50:24 +0200
parents 345f86fd1ac3
children 7a4d586caf2d
comparison
equal deleted inserted replaced
3364:ea299aca479b 3365:9345710bbf12
221 221
222 // 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) 222 // 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)
223 ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 1, 2)); 223 ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 1, 2));
224 ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 2, 4)); 224 ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 2, 4));
225 } 225 }
226
227 TYPED_TEST(TestIntegerImageTraits, FillPolygonLargerThandImage)
228 {
229 ImageAccessor& image = this->GetImage();
230
231 ImageProcessing::Set(image, 0);
232
233 std::vector<ImageProcessing::ImagePoint> points;
234 points.push_back(ImageProcessing::ImagePoint(0, 0));
235 points.push_back(ImageProcessing::ImagePoint(image.GetWidth(),0));
236 points.push_back(ImageProcessing::ImagePoint(image.GetWidth(),image.GetHeight()));
237 points.push_back(ImageProcessing::ImagePoint(0,image.GetHeight()));
238
239 ASSERT_THROW(Orthanc::ImageProcessing::FillPolygon(image, points, 255), Orthanc::OrthancException);
240
241 // 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)
242 ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 0, 0));
243 ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, image.GetWidth()-1, 0));
244 }
245
246 TYPED_TEST(TestIntegerImageTraits, FillPolygonFullImage)
247 {
248 ImageAccessor& image = this->GetImage();
249
250 ImageProcessing::Set(image, 0);
251
252 std::vector<ImageProcessing::ImagePoint> points;
253 points.push_back(ImageProcessing::ImagePoint(0, 0));
254 points.push_back(ImageProcessing::ImagePoint(image.GetWidth() - 1,0));
255 points.push_back(ImageProcessing::ImagePoint(image.GetWidth() - 1,image.GetHeight() - 1));
256 points.push_back(ImageProcessing::ImagePoint(0,image.GetHeight() - 1));
257
258 Orthanc::ImageProcessing::FillPolygon(image, points, 255);
259
260 // 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)
261 ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, 1, 1));
262 ASSERT_FLOAT_EQ(255, TestFixture::ImageTraits::GetFloatPixel(image, image.GetWidth() - 2, image.GetHeight() - 2));
263 }