How to use the imgviz.data function in imgviz

To help you get started, we’ve selected a few imgviz examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wkentaro / imgviz / tests / test_label.py View on Github external
def test_label2rgb():
    data = imgviz.data.arc2017()
    H, W = data["class_label"].shape[:2]

    labelviz = imgviz.label2rgb(label=data["class_label"])
    assert labelviz.dtype == np.uint8
    assert labelviz.shape == (H, W, 3)

    labelviz = imgviz.label2rgb(label=data["class_label"], img=data["rgb"])
    assert labelviz.dtype == np.uint8
    assert labelviz.shape == (H, W, 3)

    labelviz = imgviz.label2rgb(
        label=data["class_label"],
        img=data["rgb"],
        label_names=data["class_names"],
    )
    assert labelviz.dtype == np.uint8
github wkentaro / imgviz / tests / test_flow.py View on Github external
def test_flow2rgb():
    data = imgviz.data.middlebury()

    flow = data["flow"]
    flowviz = imgviz.flow2rgb(flow)

    assert flowviz.dtype == np.uint8
    H, W = flow.shape[:2]
    assert flowviz.shape == (H, W, 3)
github wkentaro / imgviz / getting_started.py View on Github external
#!/usr/bin/env python
# flake8: noqa

import os.path as osp

import matplotlib.pyplot as plt

here = osp.dirname(osp.abspath(__file__))  # NOQA

# -----------------------------------------------------------------------------
# GETTING_STARTED {{
import imgviz


# sample data of rgb, depth, class label and instance masks
data = imgviz.data.arc2017()

# colorize depth image with JET colormap
depth = data["depth"]
depthviz = imgviz.depth2rgb(depth, min_value=0.3, max_value=1)

# colorize label image
class_label = data["class_label"]
labelviz = imgviz.label2rgb(class_label, label_names=data["class_names"])

# instance bboxes
rgb = data["rgb"]
bboxes = data["bboxes"].astype(int)
labels = data["labels"]
captions = [data["class_names"][l] for l in labels]
bboxviz = imgviz.instances2rgb(image=rgb, bboxes=bboxes, labels=labels, captions=captions)
github wkentaro / imgviz / examples / nchannel2rgb.py View on Github external
def nchannel2rgb():
    data = imgviz.data.arc2017()

    np.random.seed(1234)  # for PCA
    nchannel_viz = imgviz.nchannel2rgb(data["res4"], dtype=np.float32)

    H, W = data["rgb"].shape[:2]
    nchannel_viz = imgviz.resize(nchannel_viz, height=H, width=W)
    nchannel_viz = (nchannel_viz * 255).round().astype(np.uint8)

    # -------------------------------------------------------------------------

    plt.figure(dpi=200)

    plt.subplot(121)
    plt.title("rgb")
    plt.imshow(data["rgb"])
    plt.axis("off")
github wkentaro / imgviz / examples / centerize.py View on Github external
def centerize():
    data = imgviz.data.arc2017()

    rgb = data["rgb"]

    H, W = rgb.shape[:2]
    centerized1 = imgviz.centerize(rgb, shape=(H, H))

    rgb_T = rgb.transpose(1, 0, 2)
    centerized2 = imgviz.centerize(rgb_T, shape=(H, H))

    # -------------------------------------------------------------------------

    plt.figure(dpi=200)

    plt.subplot(131)
    plt.title("original")
    plt.axis("off")
github wkentaro / imgviz / examples / flow2rgb.py View on Github external
def flow2rgb():
    data = imgviz.data.middlebury()

    rgb = data["rgb"]
    flowviz = imgviz.flow2rgb(data["flow"])

    # -------------------------------------------------------------------------

    plt.figure(dpi=200)

    plt.subplot(121)
    plt.title("image")
    plt.imshow(rgb)
    plt.axis("off")

    plt.subplot(122)
    plt.title("flow")
    plt.imshow(flowviz)
github wkentaro / imgviz / examples / label2rgb.py View on Github external
def label2rgb():
    data = imgviz.data.voc()

    rgb = data["rgb"]
    label = data["class_label"]

    label_names = [
        "{}:{}".format(i, n) for i, n in enumerate(data["class_names"])
    ]
    labelviz_withname1 = imgviz.label2rgb(
        label, label_names=label_names, font_size=25
    )
    labelviz_withname2 = imgviz.label2rgb(
        label, label_names=label_names, font_size=25, loc="rb"
    )
    img = imgviz.color.rgb2gray(rgb)
    labelviz_withimg = imgviz.label2rgb(label, img=img)
github wkentaro / imgviz / examples / instances2rgb.py View on Github external
def instances2rgb():
    data = imgviz.data.voc()

    captions = [data["class_names"][l] for l in data["labels"]]
    insviz1 = imgviz.instances2rgb(
        image=data["rgb"],
        bboxes=data["bboxes"],
        labels=data["labels"],
        captions=captions,
    )
    insviz2 = imgviz.instances2rgb(
        image=data["rgb"],
        masks=data["masks"] == 1,
        labels=data["labels"],
        captions=captions,
    )

    # -------------------------------------------------------------------------
github wkentaro / imgviz / examples / resize.py View on Github external
def resize():
    data = imgviz.data.arc2017()

    rgb = data["rgb"]

    H, W = rgb.shape[:2]
    rgb_resized = imgviz.resize(rgb, height=0.1)

    # -------------------------------------------------------------------------

    plt.figure(dpi=200)

    plt.subplot(121)
    plt.title("rgb:\n{}".format(rgb.shape))
    plt.imshow(rgb)
    plt.axis("off")

    plt.subplot(122)