Open .mat file containing images

12 次查看(过去 30 天)
Serena Lew
Serena Lew 2019-1-12
Hi, I am trying to open a .mat folder that contains 2 objects: IMG1N and IMG2. Object IMG1N has 12 images that I need to perform contrast-noise-ratio analysis on. However, I haven't been able to extract and use the 12 images. I have been searching the internet but I dont understand how. This is one of the codes I tried.
allimages = load('A1images.mat')
whos
image(allimages.IMG1N)
colormap(allimages.map)
And this is the result I have been getting
allimages =
struct with fields:
IMG1N: [256×256×12 double]
IMG2: [300×400 double]
Name Size Bytes Class Attributes
allimages 1x1 7251808 struct
Error using image
Color data must be an m-by-n-by-3 or m-by-n matrix.
Error in untitled (line 8)
image(allimages.IMG1N)
Please help , I do think it's probably a very simple solution but I just can't figure how.

回答(1 个)

ILoveMATLAB
ILoveMATLAB 2019-1-13
Image() fucntion requires either an m-by-n-by-3 or m-by-n. When you write
image(allimages.IMG1N)
you are giving the image function an m by n by 12 array
If you want to view one of the images, you must call image like this
image(allimages.IMG1N(:,:,1));
If you have the image processing tool box, you should use imshow.
imshow(allimages.IMG1N(:,:,1));
If you want to view the other images, just change the number 1 to the image you want to view.
  2 个评论
Walter Roberson
Walter Roberson 2019-1-13
I disagree about the use of the word "should" about imshow(). My recommendation is to use imshow() only for interactive exploration or very basic tools, and to get rid of it as soon as your GUI has any meaningful complexity. imshow() does a lot behind your back that can badly interfere with GUI development.
Walter Roberson
Walter Roberson 2019-1-13
If the images are intended to be a sequence rather than a volume, then you could consider using implay() to animate them.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Import, Export, and Conversion 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by