fossasia / visdom

A flexible tool for creating, organizing, and sharing visualizations of live, rich data. Supports Torch and Numpy.
Apache License 2.0
9.97k stars 1.14k forks source link

Adding support for alpha channels #694

Open Wicloz opened 4 years ago

Wicloz commented 4 years ago

Currently, this project supports displaying greyscale and RGB images. However, many digital images also contain an alpha channel, and it would be nice to display images as RGBA, rather than converting them to RGB.

My initial investigation shows that simply changing the depth of the first axis from 3 to 4 in https://github.com/facebookresearch/visdom/blob/master/py/visdom/__init__.py#L1268 allows for proper display of RGBA images. Grayscale and RGB images would need to be converted to RGBA by adding a 'full' alpha channel.

Changing only the line as described above, and setting the background of the windows to green gives the following result: image

JackUrb commented 4 years ago

Hi @Wicloz - this seems like a reasonable feature to add, though it definitely would need to still support the default case. I'd be happy to accept a PR that implements this properly. (You could also include an opt for specifying the window's background color somehow, and catch instances that set a background but aren't passing a 4 channel image.

Wicloz commented 4 years ago

It should be fairly easy to add a full alpha channel to RGB or grey images, I'll work on this when I have some time.