preprocess/patchExtractor.py
def unpatch_block(blocks, tile_dim, patch_size, tile_dim_output=None, patch_size_output=None, overlap=0):
    """
    Unpatch a block, set tile_dim_output and patch_size_output to a proper number if padding exits
    :param blocks: data blocks, should be n*h*w*c
    :param tile_dim: input tile dimension, if padding exits should be h+2*pad, w+2*pad
    :param patch_size: input patch size
    :param tile_dim_output: output tile dimension
    :param patch_size_output: output patch dimension, if shrinking exits, should be h-2*pd, w-2*pad
    :param overlap: overlap of adjacent patches
    :return:
    """
    if tile_dim_output is None:
        tile_dim_output = tile_dim
    if patch_size_output is None:
        patch_size_output = patch_size
    _, _, _, c = blocks.shape
    image = np.zeros((tile_dim_output[0], tile_dim_output[1], c))
    for cnt, (corner_h, corner_w) in enumerate(make_grid(tile_dim, patch_size, overlap)):
        image[corner_h:corner_h + patch_size_output[0], corner_w:corner_w + patch_size_output[1], :] \
            += blocks[cnt, :, :, :]
    return image

    Unpatch a block, set tile_dim_output and patch_size_output to a proper number if padding exits
    :param blocks: data blocks, should be n*h*w*c
    :param tile_dim: input tile dimension, if padding exits should be h+2*pad, w+2*pad
    :param patch_size: input patch size
    :param tile_dim_output: output tile dimension
    :param patch_size_output: output patch dimension, if shrinking exits, should be h-2*pd, w-2*pad
    :param overlap: overlap of adjacent patches
    :return:
    
Unpatch a block, set tile_dim_output and patch_size_output to a proper number if padding exits
Unpatch a block set tile_dim_output and patch_size_output to a proper number if padding exits
def unpatch_block(blocks, tile_dim, patch_size, tile_dim_output=None, patch_size_output=None, overlap=0):
    if tile_dim_output is None:
        tile_dim_output = tile_dim
    if patch_size_output is None:
        patch_size_output = patch_size
    _, _, _, c = blocks.shape
    image = np.zeros((tile_dim_output[0], tile_dim_output[1], c))
    for cnt, (corner_h, corner_w) in enumerate(make_grid(tile_dim, patch_size, overlap)):
        image[corner_h:corner_h + patch_size_output[0], corner_w:corner_w + patch_size_output[1], :] \
            += blocks[cnt, :, :, :]
    return image
def unpatch_block ( blocks , tile_dim , patch_size , tile_dim_output = None , patch_size_output = None , overlap = 0 ) : if tile_dim_output is None : tile_dim_output = tile_dim if patch_size_output is None : patch_size_output = patch_size _ , _ , _ , c = blocks . shape image = np . zeros ( ( tile_dim_output [ 0 ] , tile_dim_output [ 1 ] , c ) ) for cnt , ( corner_h , corner_w ) in enumerate ( make_grid ( tile_dim , patch_size , overlap ) ) : image [ corner_h : corner_h + patch_size_output [ 0 ] , corner_w : corner_w + patch_size_output [ 1 ] , : ] += blocks [ cnt , : , : , : ] return image
Unpatch a block, set tile_dim_output and patch_size_output to a proper number if padding exits
Unpatch a block set tile_dim_output and patch_size_output to a proper number if padding exits
"""
    Unpatch a block, set tile_dim_output and patch_size_output to a proper number if padding exits
    :param blocks: data blocks, should be n*h*w*c
    :param tile_dim: input tile dimension, if padding exits should be h+2*pad, w+2*pad
    :param patch_size: input patch size
    :param tile_dim_output: output tile dimension
    :param patch_size_output: output patch dimension, if shrinking exits, should be h-2*pd, w-2*pad
    :param overlap: overlap of adjacent patches
    :return:
    """
None
blocks
data blocks, should be n*h*w*c
data blocks should be n * h * w * c
tile_dim
input tile dimension, if padding exits should be h+2*pad, w+2*pad
input tile dimension if padding exits should be h + 2 * pad w + 2 * pad
patch_size
input patch size
input patch size
tile_dim_output
output tile dimension
output tile dimension
patch_size_output
output patch dimension, if shrinking exits, should be h-2*pd, w-2*pad
output patch dimension if shrinking exits should be h - 2 * pd w - 2 * pad
overlap
overlap of adjacent patches
overlap of adjacent patches