示例#1
0
def test_scale(target):
    img = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]],
                   dtype=np.uint8)
    expected = np.array(
        [[1, 1, 2, 2, 3, 3], [2, 2, 2, 3, 3, 4], [3, 3, 4, 4, 5, 5],
         [5, 5, 5, 6, 6, 7], [6, 6, 7, 7, 8, 8], [8, 8, 8, 9, 9, 10],
         [9, 9, 10, 10, 11, 11], [10, 10, 11, 11, 12, 12]],
        dtype=np.uint8)

    img, expected = convert_2d_to_target_format([img, expected], target=target)
    scaled = F.scale(img, scale=2, interpolation=cv2.INTER_LINEAR)
    assert np.array_equal(scaled, expected)
示例#2
0
 def apply(self, image, scale=1.0, **params):
     return F.scale(image, scale, interpolation=self.interpolation)
示例#3
0
 def apply(self, img, interpolation=1, **params):
     im_sz = np.array([params["cols"], params["rows"]])
     scale = min(self.target_wh / im_sz)
     return F.scale(img, scale=scale, interpolation=interpolation)
示例#4
0
 def apply(self, img, **params):
     return [F.scale(img, scale) for scale in self.scales]
示例#5
0
 def apply_to_mask(self, image, scale=1.0, **params):
     return F.scale(image, scale, interpolation=cv2.INTER_NEAREST)