Skip to content

v2.0.0

Choose a tag to compare

@wkentaro wkentaro released this 28 Jan 13:17
· 152 commits to main since this release

Breaking Changes

Parameter Renames:

  • imgimage and srcimage in all function arguments
  • imgsimages in tile()
  • aabb1/aabb2yx1/yx2 in draw functions
  • shapeheight/width in centerize(), row/col in tile()

Class Renames:

  • Depth2RGBDepth2Rgb
  • Nchannel2RGBNchannel2Rgb

Removed Features:

  • plot_trajectory() function (removed matplotlib dependency)
  • OpenCV backend for I/O
  • pyglet backend for I/O
  • matplotlib-based I/O functions (pyplot_imshow, pyplot_to_numpy, etc.)
  • Deprecated mask_to_bbox() (use masks_to_bboxes() instead)

Other Breaking Changes:

  • pil_imshow() renamed to imshow()
  • label_colormap() simplified (removed value parameter)
  • nchannel2rgb() parameters reordered, dtype is now keyword-only

New Features

  • mask2rgb(): New function to fill mask regions with color, with pattern fill support via imgviz.fill module
  • Flow2Rgb: New class for consistent optical flow visualization
  • py.typed: PEP 561 marker for type checker support
  • centerize(): Added loc options for "rt" (right-top) and "lb" (left-bottom)
  • flow2rgb(): Added max_norm argument for normalization control
  • asrgb(): Added copy parameter
  • star()/triangle(): Added width parameter
  • Exposed masks_to_bboxes() function

Improvements

  • Comprehensive type hints throughout the codebase
  • TypedDict return types for data functions (arc2017(), middlebury(), voc())
  • NamedTuple return type for text_in_rectangle_aabb()
  • pathlib.Path support in imread() and imsave()
  • Replaced assertions with proper ValueError exceptions
  • Improved error messages (lowercase initial letters)
  • Minimum Pillow version bumped to 10.0.0
  • Internal modules now prefixed with _
  • Google-style docstrings in draw module

Bug Fixes

  • asrgba() now correctly handles 2D grayscale images
  • centerize() handles cval=0 correctly
  • nchannel2rgb min_max_value check fixed in Nchannel2Rgb
  • label2rgb() centroid selection is now deterministic
  • Better error messages when optional dependencies (skimage, sklearn) are missing

Migration Guide

Parameter Renames

# Before (v1.x)
imgviz.resize(src=image, height=480, width=640)
imgviz.label2rgb(label=label, img=image)
imgviz.tile(imgs=[img1, img2, img3])
imgviz.draw.rectangle(img, aabb1=(10, 10), aabb2=(100, 100))

# After (v2.x)
imgviz.resize(image=image, height=480, width=640)
imgviz.label2rgb(label=label, image=image)
imgviz.tile(images=[img1, img2, img3])
imgviz.draw.rectangle(image, yx1=(10, 10), yx2=(100, 100))

Class Renames

# Before (v1.x)
depth_viz = imgviz.Depth2RGB(min_value=0, max_value=10)
nchannel_viz = imgviz.Nchannel2RGB()

# After (v2.x)
depth_viz = imgviz.Depth2Rgb(min_value=0, max_value=10)
nchannel_viz = imgviz.Nchannel2Rgb()

Shape Parameters

# Before (v1.x)
imgviz.centerize(image, shape=(480, 640))
imgviz.tile(images, shape=(2, 3))

# After (v2.x)
imgviz.centerize(image, height=480, width=640)
imgviz.tile(images, row=2, col=3)

I/O Functions

# Before (v1.x)
imgviz.io.pil_imshow(image)
imgviz.io.pyplot_imshow(image)
imgviz.io.pyglet_imshow(image)

# After (v2.x)
imgviz.io.imshow(image)  # Only PIL backend remains
# matplotlib and pyglet backends removed

Removed Functions

# Before (v1.x)
imgviz.plot_trajectory(...)  # Removed
imgviz.mask_to_bbox(mask)    # Deprecated

# After (v2.x)
# plot_trajectory: Use matplotlib directly if needed
imgviz.masks_to_bboxes(masks)  # Use this instead

label_colormap

# Before (v1.x)
colormap = imgviz.label_colormap(n_label=10, value=255)

# After (v2.x)
colormap = imgviz.label_colormap(n_label=10)
# 'value' parameter removed; colormap always uses full brightness