def pad_image ( arr , max_size = 400 ) : dim = np . max ( arr . shape ) img = np . zeros ( ( dim , dim , 3 ) , dtype = arr . dtype ) xl = ( dim - arr . shape [ 0 ] ) // 2 yl = ( dim - arr . shape [ 1 ] ) // 2 img [ xl : arr . shape [ 0 ] + xl , yl : arr . shape [ 1 ] + yl , : ] = arr return resample_image ( img , max_size = max_size )
python chang size of image resampling resolution
Pads an image to a square then resamples to max_size
def pad_image(arr, max_size=400):
    """Pads an image to a square then resamples to max_size"""
    dim = np.max(arr.shape)
    img = np.zeros((dim, dim, 3), dtype=arr.dtype)
    xl = (dim - arr.shape[0]) // 2
    yl = (dim - arr.shape[1]) // 2
    img[xl:arr.shape[0]+xl, yl:arr.shape[1]+yl, :] = arr
    return resample_image(img, max_size=max_size)