The imshow() function is not working with .mat file

17 次查看(过去 30 天)
Hello everyone,
I am working on a project that required me to use the imshow() function to display an image. However, it is not working. I have tried different functions such as imread(), load(), but I always get an error message.
  1 个评论
hosein Javan
hosein Javan 2020-8-11
it seems "A" is of structure datatype. while "imshow" displays images in matrix form. for example RGB format requires a matrix of size "m*n*3". select one of its fields using command "B=A.field1" where "field1" is the name of the field then use "imshow(B)". it depends on your data, check whether it is a matrix or not before that.

请先登录,再进行评论。

采纳的回答

Steven Lord
Steven Lord 2020-8-11
When you call load with an output argument, any variables stored in that MAT-file becomes fields in the struct array returned from load. So you'll need to imshow A.A not just A.
imshow(A.A)

更多回答(1 个)

Walter Roberson
Walter Roberson 2020-8-11
That is not possible. imshow() can load and display any image file format supported by imread() but imread() cannot read .mat files (unless they are renamed image files.)
The question does not permit you to load() the data and imshow() the results.
A case could be made, though, that it would be acceptable to load() the data from the mat and save it as an image format that imshow would be willing to load and display.
imshow does not return the content of the image you loaded, so you will need to extract it from the CData property of the image() object that imshow returns.

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

标签

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by