sphere2dice.py
def stack_fig(_patch_stack: np.ndarray, source_name='[no file name provided]',
              rotations=None):
    """
    Create a figure with six sides of a dice:
    :param rotations:
    :param _patch_stack: numpy array of size (patch_n, resolution, resolution)
    :param source_name: optional file name used in figure title
    :return: figure handle used for showing or saving
    """
    if rotations is None:
        rotations = 6 * ['']
    else:
        rotations = list(rotations)
    r = _patch_stack.shape[-1]
    stack_figure, ax = plt.subplots()

    # plot six images, each for each side of the dice
    img = np.empty([r * 3, r * 4]) * np.nan
    img[r:r * 2, r * 1:r * 2] = np.flipud(_patch_stack[0])  # center
    img[r:r * 2, r * 0:r * 1] = np.flipud(_patch_stack[1])  # left
    img[r:r * 2, r * 3:r * 4] = np.flipud(_patch_stack[2])  # far
    img[r:r * 2, r * 2:r * 3] = np.flipud(_patch_stack[3])  # right
    img[r * 0:r * 1, r:r * 2] = np.flipud(_patch_stack[4])  # up
    img[r * 2:r * 3, r:r * 2] = np.flipud(_patch_stack[5])  # down
    ax.imshow(img, cmap='jet', vmin=0, vmax=5)

    # place text
    ax.text(r * 1, r, '[0] center ' + str(rotations[0]), va='top')  # center
    ax.text(r * 2, r, '[1] right ' + str(rotations[1]), va='top')  # right
    ax.text(r * 3, r, '[2] far ' + str(rotations[2]), va='top')  # far
    ax.text(r * 0, r, '[3] left ' + str(rotations[3]), va='top')  # left
    ax.text(r * 1, 0, '[4] up ' + str(rotations[4]), va='top')  # up
    ax.text(r * 1, r * 2, '[5] down ' + str(rotations[5]), va='top')  # down

    # formatting
    ax.axis('off')
    ax.axis('equal')
    ax.set_title(f'UV map of 6/{len(_patch_stack)}patches for\n{basename(source_name)}')
    return stack_figure

    Create a figure with six sides of a dice:
    :param rotations:
    :param _patch_stack: numpy array of size (patch_n, resolution, resolution)
    :param source_name: optional file name used in figure title
    :return: figure handle used for showing or saving
    
Create a figure with six sides of a dice.
Create a figure with six sides of a dice .
def stack_fig(_patch_stack: np.ndarray, source_name='[no file name provided]',
              rotations=None):
    if rotations is None:
        rotations = 6 * ['']
    else:
        rotations = list(rotations)
    r = _patch_stack.shape[-1]
    stack_figure, ax = plt.subplots()
    img = np.empty([r * 3, r * 4]) * np.nan
    img[r:r * 2, r * 1:r * 2] = np.flipud(_patch_stack[0])  
    img[r:r * 2, r * 0:r * 1] = np.flipud(_patch_stack[1])  
    img[r:r * 2, r * 3:r * 4] = np.flipud(_patch_stack[2])  
    img[r:r * 2, r * 2:r * 3] = np.flipud(_patch_stack[3])  
    img[r * 0:r * 1, r:r * 2] = np.flipud(_patch_stack[4])  
    img[r * 2:r * 3, r:r * 2] = np.flipud(_patch_stack[5])  
    ax.imshow(img, cmap='jet', vmin=0, vmax=5)
    ax.text(r * 1, r, '[0] center ' + str(rotations[0]), va='top')  
    ax.text(r * 2, r, '[1] right ' + str(rotations[1]), va='top')  
    ax.text(r * 3, r, '[2] far ' + str(rotations[2]), va='top')  
    ax.text(r * 0, r, '[3] left ' + str(rotations[3]), va='top')  
    ax.text(r * 1, 0, '[4] up ' + str(rotations[4]), va='top')  
    ax.text(r * 1, r * 2, '[5] down ' + str(rotations[5]), va='top')  
    ax.axis('off')
    ax.axis('equal')
    ax.set_title(f'UV map of 6/{len(_patch_stack)}patches for\n{basename(source_name)}')
    return stack_figure
def stack_fig ( _patch_stack : np . ndarray , source_name = '[no file name provided]' , rotations = None ) : if rotations is None : rotations = 6 * [ '' ] else : rotations = list ( rotations ) r = _patch_stack . shape [ - 1 ] stack_figure , ax = plt . subplots ( ) img = np . empty ( [ r * 3 , r * 4 ] ) * np . nan img [ r : r * 2 , r * 1 : r * 2 ] = np . flipud ( _patch_stack [ 0 ] ) img [ r : r * 2 , r * 0 : r * 1 ] = np . flipud ( _patch_stack [ 1 ] ) img [ r : r * 2 , r * 3 : r * 4 ] = np . flipud ( _patch_stack [ 2 ] ) img [ r : r * 2 , r * 2 : r * 3 ] = np . flipud ( _patch_stack [ 3 ] ) img [ r * 0 : r * 1 , r : r * 2 ] = np . flipud ( _patch_stack [ 4 ] ) img [ r * 2 : r * 3 , r : r * 2 ] = np . flipud ( _patch_stack [ 5 ] ) ax . imshow ( img , cmap = 'jet' , vmin = 0 , vmax = 5 ) ax . text ( r * 1 , r , '[0] center ' + str ( rotations [ 0 ] ) , va = 'top' ) ax . text ( r * 2 , r , '[1] right ' + str ( rotations [ 1 ] ) , va = 'top' ) ax . text ( r * 3 , r , '[2] far ' + str ( rotations [ 2 ] ) , va = 'top' ) ax . text ( r * 0 , r , '[3] left ' + str ( rotations [ 3 ] ) , va = 'top' ) ax . text ( r * 1 , 0 , '[4] up ' + str ( rotations [ 4 ] ) , va = 'top' ) ax . text ( r * 1 , r * 2 , '[5] down ' + str ( rotations [ 5 ] ) , va = 'top' ) ax . axis ( 'off' ) ax . axis ( 'equal' ) ax . set_title ( f'UV map of 6/{len(_patch_stack)}patches for\n{basename(source_name)}' ) return stack_figure
Create a figure with six sides of a dice:
Create a figure with six sides of a dice :
"""
    Create a figure with six sides of a dice:
    :param rotations:
    :param _patch_stack: numpy array of size (patch_n, resolution, resolution)
    :param source_name: optional file name used in figure title
    :return: figure handle used for showing or saving
    """ # plot six images, each for each side of the dice # center # left # far # right # up # down # place text # center # right # far # left # up # down # formatting
figure handle used for showing or saving
figure handle used for showing or saving
_patch_stack
np.ndarray
numpy array of size (patch_n, resolution, resolution)
numpy array of size ( patch_n resolution resolution )
source_name
optional file name used in figure title
optional file name used in figure title
rotations
None