google / mediapy

This Python library makes it easy to display images and videos in a notebook.
https://pypi.org/project/mediapy/
Apache License 2.0
389 stars 18 forks source link

Setting vmin to a value greater than 0 can produce unexpected results for unsigned integer types #9

Closed danbgoldman closed 1 year ago

danbgoldman commented 2 years ago

Since to_rgb simply subtracts vmin from array, low pixels can underflow to high values, producing unexpected results.

I think it should be simple to fix: upcast array to int32 before subtracting vmin, and clamp to zero afterwards. But I haven't thought through edge cases.