예제 #1
0
 def test_scale_and_pad_recover(self):
     contours = [
         np.array([[5, 2], [7, 10], [9, 4], [3, 6]]),
         np.array([[1, 0], [3, 0], [3, 2]]),
         np.array([[3, 0], [3, 4], [1, 2], [5, 2], [5, 4]])
     ]
     polygons = Polygons(contours)
     polygons.scale_and_pad([0.5, 0.5], [-1, 0], recover=True)
     target_contours = [
         np.array([[2, 1], [3, 5], [4, 2], [1, 3]]),
         np.array([[0, 0], [1, 0], [1, 1]]),
         np.array([[1, 0], [1, 2], [0, 1], [2, 1], [2, 2]])
     ]
     np.testing.assert_equal(polygons.get_contours(), target_contours)
예제 #2
0
 def test_scale_and_pad_with_single_scale(self):
     contours = [
         np.array([[2, 1], [3, 5], [4, 2], [1, 3]]),
         np.array([[0, 0], [1, 0], [1, 1]]),
         np.array([[1, 0], [1, 2], [0, 1], [2, 1], [2, 2]])
     ]
     polygons = Polygons(contours)
     polygons.scale_and_pad(2, [1, 0])
     target_contours = [
         np.array([[5, 2], [7, 10], [9, 4], [3, 6]]),
         np.array([[1, 0], [3, 0], [3, 2]]),
         np.array([[3, 0], [3, 4], [1, 2], [5, 2], [5, 4]])
     ]
     np.testing.assert_equal(polygons.get_contours(), target_contours)
예제 #3
0
 def test_scale_and_pad_0(self):
     contours = []
     polygons = Polygons(contours)
     polygons.scale_and_pad([2, 2], [1, 0])
     np.testing.assert_equal(polygons.get_contours(), [])