Beispiel #1
0
    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")

    plt.subplot(122)
    plt.title("res4 (colorized)")
    plt.imshow(nchannel_viz)
    plt.axis("off")

    img = imgviz.io.pyplot_to_numpy()
    plt.close()

    return img


if __name__ == "__main__":
    from base import run_example

    run_example(nchannel2rgb)
Beispiel #2
0
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)
    plt.axis("off")

    img = imgviz.io.pyplot_to_numpy()
    plt.close()

    return img


if __name__ == "__main__":
    from base import run_example

    run_example(flow2rgb)
Beispiel #3
0
    # -------------------------------------------------------------------------

    plt.figure(dpi=200)

    plt.subplot(131)
    plt.title("+img")
    plt.imshow(labelviz_withimg)
    plt.axis("off")

    plt.subplot(132)
    plt.title("loc=centroid")
    plt.imshow(labelviz_withname1)
    plt.axis("off")

    plt.subplot(133)
    plt.title("loc=lt")
    plt.imshow(labelviz_withname2)
    plt.axis("off")

    img = imgviz.io.pyplot_to_numpy()
    plt.close()

    return img


if __name__ == "__main__":
    from base import run_example

    run_example(label2rgb)
Beispiel #4
0
    # -------------------------------------------------------------------------

    plt.figure(dpi=200)

    plt.subplot(131)
    plt.title("rgb")
    plt.imshow(data["rgb"])
    plt.axis("off")

    plt.subplot(132)
    plt.title("instances\n(bboxes)")
    plt.imshow(insviz1)
    plt.axis("off")

    plt.subplot(133)
    plt.title("instances\n(masks)")
    plt.imshow(insviz2)
    plt.axis("off")

    img = imgviz.io.pyplot_to_numpy()
    plt.close()

    return img


if __name__ == "__main__":
    from base import run_example

    run_example(instances2rgb)
Beispiel #5
0
        slice_ = slice(bbox[0], bbox[2]), slice(bbox[1], bbox[3])
        rgb_crop = rgb[slice_]
        mask_crop = mask[slice_]
        crops.append(rgb_crop * mask_crop[:, :, None])
    tiled = imgviz.tile(imgs=crops, border=(255, 255, 255))

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

    plt.figure(dpi=200)

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

    plt.subplot(122)
    plt.title("instances")
    plt.imshow(tiled)
    plt.axis("off")

    img = imgviz.io.pyplot_to_numpy()
    plt.close()

    return img


if __name__ == "__main__":
    from base import run_example

    run_example(tile)
Beispiel #6
0
        img, loc="lt+", text="original", size=30, background=(255, 255, 255),
    )
    viz = imgviz.draw.text_in_rectangle(
        viz, loc="lt+", text="markers", size=30, background=(255, 255, 255),
    )

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

    plt.figure(dpi=200)

    plt.subplot(121)
    plt.title("original")
    plt.imshow(img)
    plt.axis("off")

    plt.subplot(122)
    plt.title("markers")
    plt.imshow(viz)
    plt.axis("off")

    img = imgviz.io.pyplot_to_numpy()
    plt.close()

    return img


if __name__ == "__main__":
    from base import run_example

    run_example(draw)
Beispiel #7
0
    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)
    plt.title("rgb_resized:\n{}".format(rgb_resized.shape))
    plt.imshow(rgb_resized)
    plt.axis("off")

    img = imgviz.io.pyplot_to_numpy()
    plt.close()

    return img


if __name__ == "__main__":
    from base import run_example

    run_example(resize)
Beispiel #8
0
def depth2rgb():
    data = imgviz.data.arc2017()

    depthviz = imgviz.depth2rgb(data["depth"], min_value=0.3, max_value=1)

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

    plt.figure(dpi=200)

    plt.subplot(121)
    plt.title("rgb")
    plt.imshow(data["rgb"])
    plt.axis("off")

    plt.subplot(122)
    plt.title("depth (colorized)")
    plt.imshow(depthviz)
    plt.axis("off")

    img = imgviz.io.pyplot_to_numpy()
    plt.close()

    return img


if __name__ == "__main__":
    from base import run_example

    run_example(depth2rgb)
Beispiel #9
0
#!/usr/bin/env python

import imgviz


def plot_trajectory():
    data = imgviz.data.kitti_odometry()

    img = imgviz.plot_trajectory(data["transforms"])

    return img


if __name__ == "__main__":
    from base import run_example

    run_example(plot_trajectory)