Is this another bug in imread(), or is this just a forum problem?

2 ビュー (過去 30 日間)
DGM
DGM 2022 年 4 月 11 日
コメント済み: DGM 2023 年 1 月 24 日
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
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])
DGM
DGM 2023 年 1 月 24 日
Thank you for the attention on the matter. This will definitely simplify making examples on the forum.

サインインしてコメントする。

採用された回答

Image Analyst
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
Name Size Bytes Class Attributes alph 0x0 0 double
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
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.
DGM
DGM 2022 年 4 月 11 日
編集済み: DGM 2022 年 4 月 11 日
Thanks for getting some attention on this. I kind of expect some of the graphics tools to be nonfunctional, especially things that require interaction. That said, I don't see why imread() would behave differently, especially in such particular ways.

サインインしてコメントする。

その他の回答 (1 件)

Steve Eddins
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.

カテゴリ

Help Center および File ExchangeImages についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by