def test_crop_rescale_img(): from .pipeline_aux import crop_rescale_img from menpo.image import Image import numpy as np from menpo.shape import PointCloud test_img = Image(np.random.random([100, 100])) test_img.landmarks['PT'] = PointCloud([[20, 20], [20, 40], [40, 80], [40, 20]]) res_im = crop_rescale_img(test_img.copy()) # crop image and check reduced shapes assert(res_im.shape[0] < test_img.shape[0]) assert(res_im.shape[1] < test_img.shape[1]) res_im2 = crop_rescale_img(test_img.copy(), crop_reading=1, pix_thres=40) # check pixel threshold assert(res_im2.shape[0] < test_img.shape[0]) res_im3 = crop_rescale_img(test_img.copy(), crop_reading=1, pix_thres=400) # test that the image remains the same assert(res_im3.shape[1] > test_img.shape[1]-3)
def test_image_copy(): pixels = np.ones([1, 10, 10]) landmarks = PointCloud(np.ones([3, 2]), copy=False) im = Image(pixels, copy=False) im.landmarks['test'] = landmarks im_copy = im.copy() assert (not is_same_array(im.pixels, im_copy.pixels)) assert (not is_same_array(im_copy.landmarks['test'].points, im.landmarks['test'].points))
def test_crop_rescale_img(): from .pipeline_aux import crop_rescale_img from menpo.image import Image import numpy as np from menpo.shape import PointCloud test_img = Image(np.random.random([100, 100])) test_img.landmarks['PT'] = PointCloud([[20, 20], [20, 40], [40, 80], [40, 20]]) res_im = crop_rescale_img( test_img.copy()) # crop image and check reduced shapes assert (res_im.shape[0] < test_img.shape[0]) assert (res_im.shape[1] < test_img.shape[1]) res_im2 = crop_rescale_img(test_img.copy(), crop_reading=1, pix_thres=40) # check pixel threshold assert (res_im2.shape[0] < test_img.shape[0]) res_im3 = crop_rescale_img( test_img.copy(), crop_reading=1, pix_thres=400) # test that the image remains the same assert (res_im3.shape[1] > test_img.shape[1] - 3)