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?
Fix: support alpha array for RGB images in imshow (closes #26092)#30111
Conversation
rcomer left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
Hi@Vaishnavi-Raghupathi we do usually require new tests for code changes. Also, some of the existing tests are broken by this change, which needs to be addressed.
The issue has moved on a fair bit since it was opened. I believe the most important comment to read is#26092 (comment). You should check what the code in there produces with and without your change. I believe the remaining work is to make the bottom right subplot look like the centre right subplot, i.e. when we have an RGBA array and an alpha array passed in, the alpha of these two arrays should be blended.
# user-specified array alpha overrides the existing alpha channel | ||
A=np.dstack([A[..., :3],alpha]) | ||
else:# Scalar alpha | ||
ifA.shape[2]==3:# broadcast scalar alpha | ||
A=np.dstack([A,np.full(A.shape[:2],alpha,np.float32)]) | ||
else:# or apply scalar alpha to existing alpha channel | ||
post_apply_alpha=True |
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.
Why is this removed?
post_apply_alpha=True | ||
#to handle RGBA inputs | ||
ifA.shape[2]==4andalphaisnotNone: | ||
A[...,3]=alpha# override existing alpha channel |
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 think this is just repeating what already happened on line 518.
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.
These changes do not belong in this PR.
-->Summary
This PR fixes issue#26092 by enabling the use of a 2D alpha array with RGB images in
imshow
. Previously, passing an alpha array worked for grayscale images but was ignored for RGB images. With this change, the alpha array is correctly combined with the RGB data, allowing for per-pixel transparency in color images.--> What was changed
--> How it was tested
--> Additional notes
Closes#26092