sem_seg/vis.py
def vis_mask(image_file: str, colormap_file: str, out_path: str) -> None:
    """Visualize bitmask for one image."""
    img = np.array(Image.open(image_file))
    bitmask = np.array(Image.open(colormap_file).convert("RGB"))
    figsize = (int(1280 // 80), int(720 // 80))
    fig = plt.figure(figsize=figsize, dpi=80)
    ax: Axes = fig.add_axes([0.0, 0.0, 1.0, 1.0], frameon=False)
    ax.axis("off")
    ax.imshow(img, interpolation="bilinear", aspect="auto")
    # masking out background pixels
    mask = np.repeat((bitmask.sum(axis=2) > 0)[:, :, np.newaxis], 3, axis=2)
    ax.imshow(np.where(mask, bitmask, img), alpha=0.5)
    plt.savefig(out_path, dpi=80)
    plt.close()
Visualize bitmask for one image.
Visualize bitmask for one image.
Visualize bitmask for one image .
def vis_mask(image_file: str, colormap_file: str, out_path: str) -> None:
    img = np.array(Image.open(image_file))
    bitmask = np.array(Image.open(colormap_file).convert("RGB"))
    figsize = (int(1280 // 80), int(720 // 80))
    fig = plt.figure(figsize=figsize, dpi=80)
    ax: Axes = fig.add_axes([0.0, 0.0, 1.0, 1.0], frameon=False)
    ax.axis("off")
    ax.imshow(img, interpolation="bilinear", aspect="auto")
    mask = np.repeat((bitmask.sum(axis=2) > 0)[:, :, np.newaxis], 3, axis=2)
    ax.imshow(np.where(mask, bitmask, img), alpha=0.5)
    plt.savefig(out_path, dpi=80)
    plt.close()
def vis_mask ( image_file : str , colormap_file : str , out_path : str ) -> None : img = np . array ( Image . open ( image_file ) ) bitmask = np . array ( Image . open ( colormap_file ) . convert ( "RGB" ) ) figsize = ( int ( 1280 // 80 ) , int ( 720 // 80 ) ) fig = plt . figure ( figsize = figsize , dpi = 80 ) ax : Axes = fig . add_axes ( [ 0.0 , 0.0 , 1.0 , 1.0 ] , frameon = False ) ax . axis ( "off" ) ax . imshow ( img , interpolation = "bilinear" , aspect = "auto" ) mask = np . repeat ( ( bitmask . sum ( axis = 2 ) > 0 ) [ : , : , np . newaxis ] , 3 , axis = 2 ) ax . imshow ( np . where ( mask , bitmask , img ) , alpha = 0.5 ) plt . savefig ( out_path , dpi = 80 ) plt . close ( )
Visualize bitmask for one image.
Visualize bitmask for one image .
"""Visualize bitmask for one image.""" # masking out background pixels
image_file
str
colormap_file
str
out_path
str