Is this another bug in imread(), or is this just a forum problem?
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Steve Eddins
2023 年 1 月 24 日
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])
採用された回答
Image Analyst
2022 年 4 月 11 日
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 件のコメント
Image Analyst
2022 年 4 月 11 日
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.
その他の回答 (1 件)
Steve Eddins
2022 年 4 月 12 日
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.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!