image_super_resolution/utils.py
def segmented_process(M, blk_size, fun=None):
    """processes the image M by applying the function fun to each distinct block of size blk_size and concatenating the results into the output matrix, M_res.

    Args:
        M (np.array): input matrix
        blk_size (tuple): size of blocks to process
        fun (lambda function, optional): function to apply. Defaults to None.

    Returns:
        np.array: processed matrix
    """
    rows = []
    for i in range(0, M.shape[0], blk_size[0]):
        cols = []
        for j in range(0, M.shape[1], blk_size[1]):
            cols.append(fun(M[i:i+blk_size[0], j:j+blk_size[1]]))
        rows.append(np.concatenate(cols, axis=1))
    M_res = np.concatenate(rows, axis=0)
    return M_res
processes the image M by applying the function fun to each distinct block of size blk_size and concatenating the results into the output matrix, M_res.

    Args:
        M (np.array): input matrix
        blk_size (tuple): size of blocks to process
        fun (lambda function, optional): function to apply. Defaults to None.

    Returns:
        np.array: processed matrix
    
processes the image M by applying the function fun to each distinct block of size blk_size and concatenating the results into the output matrix, M_res.
processes the image M by applying the function fun to each distinct block of size blk_size and concatenating the results into the output matrix M_res .
def segmented_process(M, blk_size, fun=None):
    rows = []
    for i in range(0, M.shape[0], blk_size[0]):
        cols = []
        for j in range(0, M.shape[1], blk_size[1]):
            cols.append(fun(M[i:i+blk_size[0], j:j+blk_size[1]]))
        rows.append(np.concatenate(cols, axis=1))
    M_res = np.concatenate(rows, axis=0)
    return M_res
def segmented_process ( M , blk_size , fun = None ) : rows = [ ] for i in range ( 0 , M . shape [ 0 ] , blk_size [ 0 ] ) : cols = [ ] for j in range ( 0 , M . shape [ 1 ] , blk_size [ 1 ] ) : cols . append ( fun ( M [ i : i + blk_size [ 0 ] , j : j + blk_size [ 1 ] ] ) ) rows . append ( np . concatenate ( cols , axis = 1 ) ) M_res = np . concatenate ( rows , axis = 0 ) return M_res
processes the image M by applying the function fun to each distinct block of size blk_size and concatenating the results into the output matrix, M_res.
processes the image M by applying the function fun to each distinct block of size blk_size and concatenating the results into the output matrix M_res .
"""processes the image M by applying the function fun to each distinct block of size blk_size and concatenating the results into the output matrix, M_res.

    Args:
        M (np.array): input matrix
        blk_size (tuple): size of blocks to process
        fun (lambda function, optional): function to apply. Defaults to None.

    Returns:
        np.array: processed matrix
    """
None
np.array
M
None
blk_size
size of blocks to process
size of blocks to process
fun
function to apply. Defaults to None.
function to apply . Defaults to None .
None