The imshow() function is not working with .mat file
12 views (last 30 days)
Show older comments
Matteo Geraci
on 11 Aug 2020
Answered: Walter Roberson
on 11 Aug 2020
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 Comment
hosein Javan
on 11 Aug 2020
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.
Accepted Answer
Steven Lord
on 11 Aug 2020
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)
0 Comments
More Answers (1)
Walter Roberson
on 11 Aug 2020
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.
0 Comments
See Also
Categories
Find more on Environment and Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!