(
        faces,
        textures=None,
        image_size=DEFAULT_IMAGE_SIZE,
        anti_aliasing=DEFAULT_ANTI_ALIASING,
        near=DEFAULT_NEAR,
        far=DEFAULT_FAR,
        eps=DEFAULT_EPS,
        background_color=DEFAULT_BACKGROUND_COLOR,
        return_rgb=True,
        return_alpha=True,
        return_depth=True,
)
return ret
Generate RGB, alpha channel, and depth images from faces and textures (for RGB).

    Args:
        faces (chainer.Variable): Faces. The shape is [batch size, number of faces, 3 (vertices), 3 (XYZ)].
        textures (chainer.Variable): Textures.
            The shape is [batch size, number of faces, texture size, texture size, texture size, 3 (RGB)].
        image_size (int): Width and height of rendered images.
        anti_aliasing (bool): do anti-aliasing by super-sampling.
        near (float): nearest z-coordinate to draw.
        far (float): farthest z-coordinate to draw.
        eps (float): small epsilon for approximated differentiation.
        background_color (tuple): background color of RGB images.
        return_rgb (bool): generate RGB images or not.
        return_alpha (bool): generate alpha channels or not.
        return_depth (bool): generate depth images or not.

    Returns:
        dict:
            {
                'rgb': RGB images. The shape is [batch size, 3, image_size, image_size].
                'alpha': Alpha channels. The shape is [batch size, image_size, image_size].
                'depth': Depth images. The shape is [batch size, image_size, image_size].
            }
Generate RGB, alpha channel, and depth images from faces and textures (for RGB).
Generate RGB alpha channel and depth images from faces and textures ( for RGB ) .
def rasterize_rgbad(
        faces,
        textures=None,
        image_size=DEFAULT_IMAGE_SIZE,
        anti_aliasing=DEFAULT_ANTI_ALIASING,
        near=DEFAULT_NEAR,
        far=DEFAULT_FAR,
        eps=DEFAULT_EPS,
        background_color=DEFAULT_BACKGROUND_COLOR,
        return_rgb=True,
        return_alpha=True,
        return_depth=True,
):
    """
    Generate RGB, alpha channel, and depth images from faces and textures (for RGB).

    Args:
        faces (chainer.Variable): Faces. The shape is [batch size, number of faces, 3 (vertices), 3 (XYZ)].
        textures (chainer.Variable): Textures.
            The shape is [batch size, number of faces, texture size, texture size, texture size, 3 (RGB)].
        image_size (int): Width and height of rendered images.
        anti_aliasing (bool): do anti-aliasing by super-sampling.
        near (float): nearest z-coordinate to draw.
        far (float): farthest z-coordinate to draw.
        eps (float): small epsilon for approximated differentiation.
        background_color (tuple): background color of RGB images.
        return_rgb (bool): generate RGB images or not.
        return_alpha (bool): generate alpha channels or not.
        return_depth (bool): generate depth images or not.

    Returns:
        dict:
            {
                'rgb': RGB images. The shape is [batch size, 3, image_size, image_size].
                'alpha': Alpha channels. The shape is [batch size, image_size, image_size].
                'depth': Depth images. The shape is [batch size, image_size, image_size].
            }

    """

    if textures is None:
        inputs = [faces]
    else:
        inputs = [faces, textures]

    if anti_aliasing:
        # 2x super-sampling
        rgb, alpha, depth = Rasterize(
            image_size * 2, near, far, eps, background_color, return_rgb, return_alpha, return_depth)(*inputs)
    else:
        rgb, alpha, depth = Rasterize(
            image_size, near, far, eps, background_color, return_rgb, return_alpha, return_depth)(*inputs)

    # transpose & vertical flip
    if return_rgb:
        rgb = rgb.transpose((0, 3, 1, 2))
        rgb = rgb[:, :, ::-1, :]
    if return_alpha:
        alpha = alpha[:, ::-1, :]
    if return_depth:
        depth = depth[:, ::-1, :]

    if anti_aliasing:
        # 0.5x down-sampling
        if return_rgb:
            rgb = cf.average_pooling_2d(rgb, 2, 2)
        if return_alpha:
            alpha = cf.average_pooling_2d(alpha[:, None, :, :], 2, 2)[:, 0]
        if return_depth:
            depth = cf.average_pooling_2d(depth[:, None, :, :], 2, 2)[:, 0]

    ret = {
        'rgb': rgb if return_rgb else None,
        'alpha': alpha if return_alpha else None,
        'depth': depth if return_depth else None,
    }

    return ret
def rasterize_rgbad ( faces , textures = None , image_size = DEFAULT_IMAGE_SIZE , anti_aliasing = DEFAULT_ANTI_ALIASING , near = DEFAULT_NEAR , far = DEFAULT_FAR , eps = DEFAULT_EPS , background_color = DEFAULT_BACKGROUND_COLOR , return_rgb = True , return_alpha = True , return_depth = True , ) : if textures is None : inputs = [ faces ] else : inputs = [ faces , textures ] if anti_aliasing : # 2x super-sampling rgb , alpha , depth = Rasterize ( image_size * 2 , near , far , eps , background_color , return_rgb , return_alpha , return_depth ) ( * inputs ) else : rgb , alpha , depth = Rasterize ( image_size , near , far , eps , background_color , return_rgb , return_alpha , return_depth ) ( * inputs ) # transpose & vertical flip if return_rgb : rgb = rgb . transpose ( ( 0 , 3 , 1 , 2 ) ) rgb = rgb [ : , : , : : - 1 , : ] if return_alpha : alpha = alpha [ : , : : - 1 , : ] if return_depth : depth = depth [ : , : : - 1 , : ] if anti_aliasing : # 0.5x down-sampling if return_rgb : rgb = cf . average_pooling_2d ( rgb , 2 , 2 ) if return_alpha : alpha = cf . average_pooling_2d ( alpha [ : , None , : , : ] , 2 , 2 ) [ : , 0 ] if return_depth : depth = cf . average_pooling_2d ( depth [ : , None , : , : ] , 2 , 2 ) [ : , 0 ] ret = { 'rgb' : rgb if return_rgb else None , 'alpha' : alpha if return_alpha else None , 'depth' : depth if return_depth else None , } return ret