Is this another bug in imread(), or is this just a forum problem?
2 views (last 30 days)
Show older comments
I've been finding that imread() will no longer correctly process images with alpha content when I try to use it in forum posts.
Attached is a simple test image consisting of a flat purple field, and an object shape defined strictly by alpha alone.
When I run the following test in the forum editor (R2022a), I get this garbage:
A = imread('icon.png');
[B,~,alph] = imread('icon.png');
montage({A B alph},'size',[1 3])
I shouldn't have to say that's wrong. This is what R2019b shows. The second and third images are the color and alpha content as described. The first image is the composed image that imread() frustratingly (but expectedly) returns when the short syntax is used.
So imread() appears to no longer be able to handle images with alpha. It behaves like the short syntax is being used, returning a composed image and an empty array for alpha.
I'm calling on people with newer versions than I have. Is this another new bug in the R2022a version of imread(), or is this just something that's broken only on the forum editor for some reason? The attached image and code snippet should suffice for a test.
3 Comments
Steve Eddins
on 24 Jan 2023
This problem has now been fixed in MATLAB Answers.
A = imread('icon.png');
[B,~,alph] = imread('icon.png');
montage({A B alph},'size',[1 3])
Accepted Answer
Image Analyst
on 11 Apr 2022
Running the code in the Answers editor gives you first image you posted, without the black head. If you run it in desktop MATLAB 2022a you get the second image with the white head.
[B,~,alph] = imread('icon.png');
whos alph
If I run the same code it in the Desktop I get
Name Size Bytes Class Attributes
alph 160x160 25600 uint8
I don't know why there is a difference.
3 Comments
Image Analyst
on 11 Apr 2022
I've let the developer know, but the forum definitely does not have all the full capability of desktop MATLAB particularly when it comes to display things or interacting with the display or image. For example, the impixelinfo function, as simple as that is, doesn't work if called from the Answers editor.
More Answers (1)
Steve Eddins
on 12 Apr 2022
I can reproduce the problem in MATLAB Answers. The problem does not occur in MATLAB Online or in the desktop version.
I'll let the MATLAB Answers team know.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!