Esempio n. 1
0
def test_pad_to_square(img):
    img_pad = mv.pad_to_square(img)
    assert_image_equal(img, img_pad)

    img_crop = mv.crop(img, 32, 0, 64, 128)
    img_pad = mv.pad_to_square(img_crop, cv2.BORDER_CONSTANT)
    roi = mv.crop(img_pad, 32, 0, 64, 128)
    assert_image_equal(img_crop, roi)
    img_pad[32:32 + 64, :] = 0
    assert img_pad.max() == 0

    img_pad = mv.pad_to_square(img_crop)
    roi = mv.crop(img_pad, 32, 0, 64, 128)
    assert_image_equal(img_crop, roi)
Esempio n. 2
0
def test_center_crop(img):
    roi = mv.center_crop(img, 128, 128)
    assert_image_equal(img, roi)

    roi = mv.center_crop(img, 64, 64)
    roi_2 = mv.crop(img, 32, 32, 64, 64)
    assert_image_equal(roi, roi_2)
Esempio n. 3
0
def test_crop(img):
    i, j, h, w = 1, 2, 27, 18
    roi = mv.crop(img, i, j, h, w)
    img_refill = img.copy()
    img_refill[i:i + h, j:j + w] = roi
    assert_image_equal(img, img_refill)