v2.0.0
Breaking Changes
Parameter Renames:
img→imageandsrc→imagein all function argumentsimgs→imagesintile()aabb1/aabb2→yx1/yx2in draw functionsshape→height/widthincenterize(),row/colintile()
Class Renames:
Depth2RGB→Depth2RgbNchannel2RGB→Nchannel2Rgb
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()(usemasks_to_bboxes()instead)
Other Breaking Changes:
pil_imshow()renamed toimshow()label_colormap()simplified (removedvalueparameter)nchannel2rgb()parameters reordered,dtypeis now keyword-only
New Features
mask2rgb(): New function to fill mask regions with color, with pattern fill support viaimgviz.fillmoduleFlow2Rgb: New class for consistent optical flow visualizationpy.typed: PEP 561 marker for type checker supportcenterize(): Addedlocoptions for"rt"(right-top) and"lb"(left-bottom)flow2rgb(): Addedmax_normargument for normalization controlasrgb(): Addedcopyparameterstar()/triangle(): Addedwidthparameter- Exposed
masks_to_bboxes()function
Improvements
- Comprehensive type hints throughout the codebase
TypedDictreturn types for data functions (arc2017(),middlebury(),voc())NamedTuplereturn type fortext_in_rectangle_aabb()pathlib.Pathsupport inimread()andimsave()- Replaced assertions with proper
ValueErrorexceptions - 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 imagescenterize()handlescval=0correctlynchannel2rgbmin_max_valuecheck fixed inNchannel2Rgblabel2rgb()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 removedRemoved 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 insteadlabel_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