Пример #1
0
def padding_square(img):

    img = exposure.adjust_gamma(img, 0.15)
    (vertical_pixel, horizontal_pixel) = img.shape
    if vertical_pixel > horizontal_pixel:
        horizontal_padding = int(round(vertical_pixel - horizontal_pixel))
        horizontal_padding = int(horizontal_padding/1)
        padding = ((0, 0), (horizontal_padding, horizontal_padding))
    else:
        vertical_padding = int(round(horizontal_pixel - vertical_pixel))
        vertical_padding = int(vertical_padding/2)
        padding = ((vertical_padding, vertical_padding), (0, 0))
    img = skimage.util.pad(img, padding, 'constant', constant_values=0)
    return img
Пример #2
0
def padding_square(img):
    """
    :type img: ndarray
    :rtype: ndarray
    """
    # TODO: add padding to right/bottom side of img and make it a square
    img = exposure.adjust_gamma(img, 0.15)
    (vertical_pixel, horizontal_pixel) = img.shape
    if vertical_pixel > horizontal_pixel:
        horizontal_padding = int(round(vertical_pixel - horizontal_pixel))
        horizontal_padding = int(horizontal_padding / 1)
        padding = ((0, 0), (horizontal_padding, horizontal_padding))
    else:
        vertical_padding = int(round(horizontal_pixel - vertical_pixel))
        vertical_padding = int(vertical_padding / 2)
        padding = ((vertical_padding, vertical_padding), (0, 0))
    img = skimage.util.pad(img, padding, 'constant', constant_values=0)
    return img