(img, target_size)
return padded_img
Pad an image up to the target size.
Pad an image up to the target size.
Pad an image up to the target size .
def pad_image(img, target_size):
    """Pad an image up to the target size."""
    rows_missing = target_size[0] - img.shape[2]
    cols_missing = target_size[1] - img.shape[3]
    padded_img = np.pad(img, ((0, 0), (0, 0), (0, rows_missing), (0, cols_missing)), 'constant')
    return padded_img
def pad_image ( img , target_size ) : rows_missing = target_size [ 0 ] - img . shape [ 2 ] cols_missing = target_size [ 1 ] - img . shape [ 3 ] padded_img = np . pad ( img , ( ( 0 , 0 ) , ( 0 , 0 ) , ( 0 , rows_missing ) , ( 0 , cols_missing ) ) , 'constant' ) return padded_img