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

조회 수: 3 (최근 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.

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by