Skip to content
Projects

About

Rich Image Visualization with Minimum Dependency (no OpenCV, Matplotlib)

Design & Media

How these counts are measured

Measured star growth

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
Collecting history

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

README.md

Original

imgviz

Image Visualization Tools


Installation

pip install imgviz

# there are optional dependencies like skimage, below installs all.
pip install imgviz[all]

Dependencies

Getting Started

# getting_started.py

import numpy as np

import imgviz

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

rgb = data["rgb"]
gray = imgviz.rgb2gray(rgb)

# colorize depth image with viridis colormap
depth = data["depth"]
depthviz = imgviz.colorize(depth, vmin=0.3, vmax=1)

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

# instance bboxes
bboxes = data["bboxes"].astype(int)
labels = data["labels"]
masks = data["masks"] == 1
captions = [data["class_names"][l] for l in labels]
maskviz = imgviz.instances2rgb(gray, masks=masks, labels=labels, captions=captions)

# per-instance flags as pie glyphs
centers = np.array([np.argwhere(m).mean(axis=0) for m in masks])
flags = np.column_stack(
    (masks.sum(axis=(1, 2)) < 7000, centers[:, 1] < rgb.shape[1] / 2)
)
flagviz = imgviz.flags2rgb(
    gray, flags=flags, centers=centers, flag_names=["small", "left"], wedges="on"
)

# tile instance masks
insviz = [
    (rgb * m[:, :, None])[b[0] : b[2], b[1] : b[3]] for b, m in zip(bboxes, masks)
]
insviz = imgviz.tile(images=insviz, border=(255, 255, 255))
insviz = imgviz.resize(insviz, height=rgb.shape[0])

# tile visualization
tiled = imgviz.tile(
    [rgb, depthviz, labelviz, maskviz, flagviz, insviz],
    row=2,
    col=3,
    border=(255, 255, 255),
    border_width=5,
)

Examples

examples/blur_pixelate.py
examples/box_corners.py
examples/colorblind.py
examples/colorize.py
examples/diff.py
examples/draw.py
examples/flags2rgb.py
examples/flow2rgb.py
examples/heatmap.py
examples/instances2rgb.py
examples/label2rgb.py
examples/letterbox.py
examples/mask2rgb.py
examples/nchannel2rgb.py
examples/pie.py
examples/progress_bar.py
examples/resize.py
examples/rotated_rectangle.py
examples/rounded_rectangle.py
examples/scalebar.py
examples/tile.py
examples/tint.py

Explore related projects

Loading…