Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@bmorris3
Copy link
Contributor

@bmorris3 bmorris3 commented Apr 16, 2024

Description

When multiple images are loaded in image viewers in glue, the fixed resolution buffer logic chooses the data layer color and alpha for out-of-bounds regions. The logic passes in a "data value" of negative infinity, and sends that through the colormap. By default, this can give black out-of-bounds regions, which darkens the appearance of lower layers. In a simple example with two layers below, both layers have alpha=0.5, but the larger and lower layer is darker because the upper layer is rendered on top with black pixels at alpha=0.5.

Screen Shot 2024-04-16 at 11 29 52

This PR replaces -np.inf with np.nan as the default out-of-bounds value to pass into the colormap. Because of the default nan/clipping in composite_array, users shouldn't see a difference in the viewer unless they opt-in, in which case they will see:

Screen Shot 2024-04-16 at 11 36 52

To opt in (after this PR), select a colormap with a transparent bad pixel:

import matplotlib.pyplot as plt
cmap = plt.cm.gray.with_extremes(bad=(0, 0, 0, 0))

and allow the bad alpha to be shown (since #2468):

layer.composite._allow_bad_alpha = True

Copy link
Member

@astrofrog astrofrog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants