preprocess/patchExtractor.py
def patch_block(block, pad, grid_list, patch_size, return_coord=False):
    """
    make a data block into patches
    :param block: data block to be patched, shold be h*w*c
    :param pad: #pixels to pad around
    :param grid_list: list of grids
    :param patch_size: size of the patch
    :param return_coord: if True, coordinates of x and y will be returned
    :return: yields patches or as well as x and y coordinates
    """
    # pad image first if it is necessary
    if pad > 0:
        block = ersa_utils.pad_image(block, pad)
    # extract images
    for y, x in grid_list:
        patch = ersa_utils.crop_image(block, y, x, patch_size[0], patch_size[1])
        if return_coord:
            yield patch, y, x
        else:
            yield patch

    make a data block into patches
    :param block: data block to be patched, shold be h*w*c
    :param pad: #pixels to pad around
    :param grid_list: list of grids
    :param patch_size: size of the patch
    :param return_coord: if True, coordinates of x and y will be returned
    :return: yields patches or as well as x and y coordinates
    
make a data block into patches
make a data block into patches
def patch_block(block, pad, grid_list, patch_size, return_coord=False):
    if pad > 0:
        block = ersa_utils.pad_image(block, pad)
    for y, x in grid_list:
        patch = ersa_utils.crop_image(block, y, x, patch_size[0], patch_size[1])
        if return_coord:
            yield patch, y, x
        else:
            yield patch
def patch_block ( block , pad , grid_list , patch_size , return_coord = False ) : if pad > 0 : block = ersa_utils . pad_image ( block , pad ) for y , x in grid_list : patch = ersa_utils . crop_image ( block , y , x , patch_size [ 0 ] , patch_size [ 1 ] ) if return_coord : yield patch , y , x else : yield patch
make a data block into patches
make a data block into patches
"""
    make a data block into patches
    :param block: data block to be patched, shold be h*w*c
    :param pad: #pixels to pad around
    :param grid_list: list of grids
    :param patch_size: size of the patch
    :param return_coord: if True, coordinates of x and y will be returned
    :return: yields patches or as well as x and y coordinates
    """ # pad image first if it is necessary # extract images
yields patches or as well as x and y coordinates
yields patches or as well as x and y coordinates
block
data block to be patched, shold be h*w*c
data block to be patched shold be h * w * c
pad
pixels to pad around
pixels to pad around
grid_list
list of grids
list of grids
patch_size
size of the patch
size of the patch
return_coord
if True, coordinates of x and y will be returned
if True coordinates of x and y will be returned