examples/nerf.py
def image_grid(
    images,
    rows=None,
    cols=None,
    fill: bool = True,
    show_axes: bool = False,
    rgb: bool = True,
    **kwargs
):
    """
    A util function for plotting a grid of images.
    Args:
        images: (N, H, W, 4) array of RGBA images
        rows: number of rows in the grid
        cols: number of columns in the grid
        fill: boolean indicating if the space between images should be filled
        show_axes: boolean indicating if the axes of the plots should be visible
        rgb: boolean, If True, only RGB channels are plotted.
            If False, only the alpha channel is plotted.
    Returns:
        None
    """
    if (rows is None) != (cols is None):
        raise ValueError("Specify either both rows and cols or neither.")

    if rows is None:
        rows = len(images)
        cols = 1

    gridspec_kw = {"wspace": 0.0, "hspace": 0.0} if fill else {}
    fig, axarr = plt.subplots(rows, cols, gridspec_kw=gridspec_kw, figsize=(15, 9))
    bleed = 0
    fig.subplots_adjust(left=bleed, bottom=bleed, right=(1 - bleed), top=(1 - bleed))

    for ax, im in zip(axarr.ravel(), images):
        if rgb:
            # only render RGB channels
            ax.imshow(im[..., :3], **kwargs)
        else:
            # only render Alpha channel
            ax.imshow(im[..., 3], **kwargs)
        if not show_axes:
            ax.set_axis_off()

    A util function for plotting a grid of images.
    Args:
        images: (N, H, W, 4) array of RGBA images
        rows: number of rows in the grid
        cols: number of columns in the grid
        fill: boolean indicating if the space between images should be filled
        show_axes: boolean indicating if the axes of the plots should be visible
        rgb: boolean, If True, only RGB channels are plotted.
            If False, only the alpha channel is plotted.
    Returns:
        None
    
A util function for plotting a grid of images.
A util function for plotting a grid of images .
def image_grid(
    images,
    rows=None,
    cols=None,
    fill: bool = True,
    show_axes: bool = False,
    rgb: bool = True,
    **kwargs
):
    if (rows is None) != (cols is None):
        raise ValueError("Specify either both rows and cols or neither.")
    if rows is None:
        rows = len(images)
        cols = 1
    gridspec_kw = {"wspace": 0.0, "hspace": 0.0} if fill else {}
    fig, axarr = plt.subplots(rows, cols, gridspec_kw=gridspec_kw, figsize=(15, 9))
    bleed = 0
    fig.subplots_adjust(left=bleed, bottom=bleed, right=(1 - bleed), top=(1 - bleed))
    for ax, im in zip(axarr.ravel(), images):
        if rgb:
            ax.imshow(im[..., :3], **kwargs)
        else:
            ax.imshow(im[..., 3], **kwargs)
        if not show_axes:
            ax.set_axis_off()
def image_grid ( images , rows = None , cols = None , fill : bool = True , show_axes : bool = False , rgb : bool = True , ** kwargs ) : if ( rows is None ) != ( cols is None ) : raise ValueError ( "Specify either both rows and cols or neither." ) if rows is None : rows = len ( images ) cols = 1 gridspec_kw = { "wspace" : 0.0 , "hspace" : 0.0 } if fill else { } fig , axarr = plt . subplots ( rows , cols , gridspec_kw = gridspec_kw , figsize = ( 15 , 9 ) ) bleed = 0 fig . subplots_adjust ( left = bleed , bottom = bleed , right = ( 1 - bleed ) , top = ( 1 - bleed ) ) for ax , im in zip ( axarr . ravel ( ) , images ) : if rgb : ax . imshow ( im [ ... , : 3 ] , ** kwargs ) else : ax . imshow ( im [ ... , 3 ] , ** kwargs ) if not show_axes : ax . set_axis_off ( )
A util function for plotting a grid of images.
A util function for plotting a grid of images .
"""
    A util function for plotting a grid of images.
    Args:
        images: (N, H, W, 4) array of RGBA images
        rows: number of rows in the grid
        cols: number of columns in the grid
        fill: boolean indicating if the space between images should be filled
        show_axes: boolean indicating if the axes of the plots should be visible
        rgb: boolean, If True, only RGB channels are plotted.
            If False, only the alpha channel is plotted.
    Returns:
        None
    """ # only render RGB channels # only render Alpha channel
None
images
(N, H, W, 4) array of RGBA images
( N H W 4 ) array of RGBA images
rows
number of rows in the grid
number of rows in the grid
cols
number of columns in the grid
number of columns in the grid
fill
bool
boolean indicating if the space between images should be filled
boolean indicating if the space between images should be filled
show_axes
bool
boolean indicating if the axes of the plots should be visible
boolean indicating if the axes of the plots should be visible
rgb
bool
boolean, If True, only RGB channels are plotted.
If False, only the alpha channel is plotted.
boolean If True only RGB channels are plotted . If False only the alpha channel is plotted .