Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Fix: support alpha array for RGB images in imshow (closes #26092)#30111
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. These changes do not belong in this PR. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -511,14 +511,17 @@ | ||
if alpha is None: # alpha parameter not specified | ||
if A.shape[2] == 3: # image has no alpha channel | ||
A = np.dstack([A, np.ones(A.shape[:2])]) | ||
elif np.ndim(alpha) > 0: # Array alpha | ||
Check failure on line 514 in lib/matplotlib/image.py
| ||
if alpha.shape != A.shape[:2]: | ||
raise ValueError("Alpha array shape must match image dimensions") | ||
Check failure on line 516 in lib/matplotlib/image.py
| ||
# user-specified array alpha overrides the existing alpha channel | ||
A = np.dstack([A[..., :3], alpha]) | ||
else: # Scalar alpha | ||
if A.shape[2] == 3: # broadcast scalar alpha | ||
A = np.dstack([A, np.full(A.shape[:2], alpha, np.float32)]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Why is this removed? | ||
#to handle RGBA inputs | ||
if A.shape[2] == 4 and alpha is not None: | ||
A[..., 3] = alpha # override existing alpha channel | ||
Check failure on line 524 in lib/matplotlib/image.py
| ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I think this is just repeating what already happened on line 518. | ||
# Resample in premultiplied alpha space. (TODO: Consider | ||
# implementing premultiplied-space resampling in | ||
# span_image_resample_rgba_affine::generate?) | ||
Uh oh!
There was an error while loading.Please reload this page.