silx icon indicating copy to clipboard operation
silx copied to clipboard

How to display the mask attached to an image?

Open t20100 opened this issue 4 years ago • 5 comments
trafficstars

Following PR #3369, in the plot, images now has an attached mask which is used to ignore values when computing the autoscaled colormap range and by tools like ColormapDialog, histogram action, profiles.

When activated (off by default to keep previous behavior), the mask tools widget displays and updates the mask attached to the image item.

The issue is when the mask tools widget is not shown, the mask attached to the image is also not shown while it is still used by the tools and colormap range computation.

So question is do we want to display the mask? and how (as NaNs, i.e., fully transparent or with a dedicated color)?... or something configurable? The configurable option sounds easy for the API (Add a ImageBase.get|setMaskVisualizationMode methods). But to have it in the toolbar it would add yet another action... unless we consider displaying it with the mask tool is enough.

t20100 avatar Feb 25 '21 09:02 t20100

I think it would be good to have it in the API.

That's the kind of stuffs I did manually for pyFAI GUI

  1. Display the non masked image
  2. Display the image with the colored mask
  3. Display the image with transparent mask

Sometimes you really care about the mask (so you want to display it colored), but sometimes it's better to just hide it.

This use cases could also be handled by extra colormap attribute style (color of mask, transparency between mask and image), but i am fine to store it in the item.

vallsv avatar Feb 25 '21 10:02 vallsv

OK. Indeed it might be a colormap attribute style too. Anyway, I'll add something in the API, but I won't use it in silx view (or any widget) for now.

t20100 avatar Feb 25 '21 10:02 t20100

Anyway, I don't think it is mandatory for 0.15, except you want to use it to clean up things. And in this case it can stays as private API.

vallsv avatar Feb 25 '21 12:02 vallsv

Inside silx I'm not sure it will allow to clean-up anything as long as we keep the previous behaviour of the MaskToolsWidget separated from the mask attached to an image.

As for the API, regarding Image item vs Colormap, all images supports a mask including RGBAImage so it cannot only be set from the Colormap.

t20100 avatar Feb 25 '21 13:02 t20100

Makes sense.

vallsv avatar Feb 25 '21 17:02 vallsv