display .mat file as an image ?

조회 수: 231 (최근 30일)
agatte
agatte 2011년 12월 6일
댓글: Image Analyst 2022년 9월 9일
Hi All Matlab users,
I have an image in .mat file ... I have a problem with display it.
clear all;
I=load ('Data.mat'); % struct double 512x512
I=I.s.I;
I=double(I);
figure(1);
imshow(I);
Could someone help me please ?
I would appreciate for any help.
  댓글 수: 2
Jan
Jan 2011년 12월 6일
Beside the useless "clear all" (see http://www.mathworks.com/matlabcentral/answers/16484-good-programming-practice#answer_22301), what is the problem? Do you get an error message - if so, which one?
Image Analyst
Image Analyst 2011년 12월 6일
Help with what? It's possible that could work if you had a variable called s, that was a structure and that had a member called I which was an array. Did you get an error or something? What does your save() function call look like - what you used when you saved "s" into Data.mat?

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2011년 12월 6일
Why don't you just do something like
% Load entire mat file contents into a structure.
% The structure has a member "I" that is a double 512x512 array.
storedStructure = load('Data.mat');
% Extract out the image from the structure into its own variable.
% Don't use I as the variable name - bad for several reasons.
imageArray = storedStructure.s.I; % Or storedStructure.I depending on what members your structure has.
% Display the image in a brand new figure window.
figure(1);
% Display double image, scaled appropriately.
% No need to cast to uint8 - could even be bad
% if your double numbers don't span the 0-255 range nicely.
imshow(imageArray, []);
  댓글 수: 6
Sharmin Afrose
Sharmin Afrose 2021년 5월 19일
Hello, I get this error:
Dot indexing is not supported for variables of this type.
Can you please help?
Image Analyst
Image Analyst 2021년 5월 19일
Sure. First read this link:
Then, in your new question (separate thread), attach your code and .mat file.

댓글을 달려면 로그인하십시오.

추가 답변 (4개)

agatte
agatte 2011년 12월 6일
It is not good . I received en error : ??? Error using ==> uint8 Conversion to uint8 from struct is not possible.
I = load('Data.mat'); figure(1); imshow(uint8(I));
????
  댓글 수: 1
Image Analyst
Image Analyst 2011년 12월 6일
Chandra's version did not accept the output of load() into a variable, like you did. In your code I would be a structure. Do what he did and leave off the I= so that "s" gets loaded into the function's workspace, then get the "I" member of "s" like you originally tried to do. But you never said what *your* code's error was, as Jan and I asked.

댓글을 달려면 로그인하십시오.


Dark
Dark 2014년 4월 9일
How do I display 512x512x5 .mat file as an image in Matlab ?
  댓글 수: 6
Tain Neupane
Tain Neupane 2022년 9월 9일
Hey Dark,
You can use imtool (X (:,:,n)) to display info slice by slice but I am not sure how to display whole image at once! I have an Image of size 512x512x125. I am having difficulties to display all at once and looking for help here. Thank you.
-Tain
Image Analyst
Image Analyst 2022년 9월 9일
If you have any more questions, then start your own completely new thread, and attach your data and code to read it in with the paperclip icon after you read this:

댓글을 달려면 로그인하십시오.


Annie micheal
Annie micheal 2016년 9월 1일
How to convert 100 face images to .mat file of the form 20*20*100 where 20*20 is the face template and 100 is the number of images.
  댓글 수: 8
Image Analyst
Image Analyst 2016년 9월 3일
Well, give it a try.
Annie micheal
Annie micheal 2016년 9월 6일
Its working.. thank u..

댓글을 달려면 로그인하십시오.


manasa p
manasa p 2018년 2월 9일
how to display 83*86*220 data set image in mat tool
  댓글 수: 2
Tain Neupane
Tain Neupane 2022년 9월 9일
Same question, I want to display an image of size 512x512x150. How do I do so using imtool or imshow or other ways? I am looking for help as soon as possible. Thank you!
Image Analyst
Image Analyst 2022년 9월 9일
You can use the volume viewer app, or you can extract a single plane and use either imtool (pops up in a new window) or imshow (uses existing axes if there is one, else makes a new one).

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Explore and Edit Images with Image Viewer App에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by