HSV image format

103 views
Skip to first unread message

Scott Pakin

unread,
Mar 29, 2020, 1:30:02 PM3/29/20
to golang-nuts
Does anyone know of a package that provides an image.Image with an HSV color model?  I've found lots of functions that convert color models but not a package that puts it all together into an Image interface.

If not, I'll write my own and make it available, but I figured I should first check if someone has already done this.

Thanks,
— Scott

Scott Pakin

unread,
Apr 1, 2020, 2:12:33 PM4/1/20
to golang-nuts
On Sunday, March 29, 2020 at 11:30:02 AM UTC-6, Scott Pakin wrote:
Does anyone know of a package that provides an image.Image with an HSV color model?  I've found lots of functions that convert color models but not a package that puts it all together into an Image interface.

If not, I'll write my own and make it available, but I figured I should first check if someone has already done this.

I'll take the lack of responses as a "no".

I went ahead and wrote my own HSV support for Go images.  The resulting hsvimage (analogous to image) and hsvimage/hsvcolor (analogous to image/color) are available from GitHub under a BSD-3 license:


This initial release supports only the NHSVA color model (non-alpha-premultiplied hue, saturation, and value with alpha channel at 8 bits per channel) and associated images.  These implement, respectively, the color.Model interface and the image.Image interface.  Caveat: HSV↔RGB conversions are slightly lossy due to 360° of hues being represented with the numbers 0–255.

Enjoy,
— Scott


Reply all
Reply to author
Forward
0 new messages