napari / product-heuristics-2020

Issues created from a product heuristics analysis of napari in Sept. 2020
BSD 3-Clause "New" or "Revised" License
2 stars 1 forks source link

Blending modes #20

Open liaprins-czi opened 4 years ago

liaprins-czi commented 4 years ago

Curious how the shapes' layer blending modes were chosen? Why wasn't "multiply" included, and others?


Recommendation

Consider expanding to more blending modes, e.g. those available in Photoshop (we,, better yet, those available in other imaging software, or go beyond their options if users would want others).

Enhancement ●○○ Low design work ▼▼▽ Medium development work

blendingmode

goanpeca commented 3 years ago

@napari/core-devs is there additional context that could be provided on this issue on why they were not added, or some of the development effort involved?

Thanks :)

tlambert03 commented 3 years ago

Those are the presets that are currently provided by vispy. Adding additional blending modes would require a little research into openGL's glBlendFuncSeparate, and (preferably) an upstream PR. Good vispy functions to start looking at are BaseGlooFunctions.set_state and set_blend_func

sofroniewn commented 3 years ago

Yes, it's also a little weird that what vispy calls additive isn't strictly additive!! i.e. it doesn't just add and saturate like you'd expect based on https://en.wikipedia.org/wiki/Blend_modes. I'm not sure what we should do about this / if it would be more confusing to change now, or if we need to expose others. I've been tripped up here myself though!

sofroniewn commented 3 years ago

I'd probably say that in the absence of further user requests adding more is low priority - i think it's more common to find more blending modes in a graphics editing tool (like a photoshop) and less common to find others in a scientific visualization tool, but if there was a use case in mind that people had for adding more we could add more.

imagesc-bot commented 3 years ago

This issue has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/saving-image-from-napari/50379/6

liaprins-czi commented 3 years ago

In the Layers tutorial (https://napari.org/tutorials/fundamentals/image.html?highlight=blending%20mode#blending-layers) (and other tutorials) on napari.org we are explaining how each of the layer modes works, but just at a very high level. For additive it says: The final blending mode additive will cause the layer to blend with the layers below even when it has full opacity. This mode is especially useful for many cell biology applications where you have multiple different components of a cell labeled in different colors.

Based on @sofroniewn 's comment above:

Yes, it's also a little weird that what vispy calls additive isn't strictly additive!! i.e. it doesn't just add and saturate like you'd expect based on https://en.wikipedia.org/wiki/Blend_modes. I'm not sure what we should do about this / if it would be more confusing to change now, or if we need to expose others. I've been tripped up here myself though!

as well as the image.sc comments, we should consider further explaining in more depth how additive blending mode does work in the interim, and perhaps in future update how it works.

For now it'd be good to update the documentation in the layers tutorial to be a little more thorough, at minimum referencing that the blending modes we have are from vispy. I could not find anywhere in the vispy docs explaining how the blending modes work or are intended to work, the closest is that link Talley shared to the actual code, but even linking to that might be more helpful than nothing.