-
Notifications
You must be signed in to change notification settings - Fork 156
Public image layer attributes for colormap 'bad' value #2556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
2fa93e3 to
382f127
Compare
382f127 to
fa9b950
Compare
| 0: composite_arr_a, | ||
|
|
||
| # masked pixels are set to opaque white | ||
| 1: np.broadcast_to((1, 1, 1, 1), (*shape, 4)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had expected update: fixed by #2556 (comment)cmap_bad_alpha==1 to produce the bad RGBA bad_color + (1,), but the actual result is (1, 1, 1, 1).
astrofrog
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall, thanks! See suggestion below for a possible fix.
Co-authored-by: Thomas Robitaille <thomas.robitaille@gmail.com>
astrofrog
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Is it ready from your side?
|
It's good for me, so long as you don't have better name suggestions. |
astrofrog
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks!
This PR adds public attributes to the image layer artist, state, and
CompositeArray. The goal is to specify how colormaps in image layers use thebadcolor and alpha.This PR is a followup to:
and specifically implements the suggestion in #2468 (comment).
Comments for discussion:
the Colormapbadfeature is specific to mpl colormaps, and in mpl docs for get/set_bad, the feature refers to "masked" values rather than "bad" values. I could rename the glue features tocmap_masked, but the reference tobadkeeps the implementation specific to matplotlib colormaps.Demo
using the three options available in comments in the loop:
cmap_bad = NoneThis is the default behavior, both before and after this PR. The out-of-bounds area is opaque black for any colormap, not just
Grays:cmap_bad = (0, 0, 0, 0)This is the use case that motivated this PR. The out-of-bounds area is completely transparent:

cmap_bad_alpha = (0, 0, 0, 1)The default Grays colormap has bad set to (0, 0, 0, 0) i.e. transparent black, so

cmap_bad_alpha=1gives opaque black: