Allow transparent regions in composite images when out of bounds #2482
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.This PR replaces
-np.inf
withnp.nan
as the default out-of-bounds value to pass into the colormap. Because of the default nan/clipping incomposite_array
, users shouldn't see a difference in the viewer unless they opt-in, in which case they will see:To opt in (after this PR), select a colormap with a transparent bad pixel:
and allow the
bad
alpha to be shown (since #2468):