creating .mat file

7 次查看(过去 30 天)
FIR
FIR 2011-10-7
Sir I have 15 images ,I want to create .mat file so that i can load these images easily,please tell how to create .mat file

采纳的回答

Wayne King
Wayne King 2011-10-7
1.) If the images are the same size you can put them in an array and save that. If different, use a cell array.
2.) You can use matfile() to create a writable .mat file, save data into it, and then load that.
matobj = matfile('c:\data\mymat','Writable',true);
matobj.image1 = randn(256,256);
matobj.image2 = randn(256,256);
loadimage1 = matobj.image1;
% or
load('mymat.mat','image1');
  5 个评论
Image Analyst
Image Analyst 2011-10-7
Single image how? Tiled, like with the montage() function? Or stacked into a volumetric 3D image like with cat(3, .....)?
FIR
FIR 2011-10-7
sir ,it is stacking of an 15 slices image into one,is it possible

请先登录,再进行评论。

更多回答(1 个)

Wayne King
Wayne King 2011-10-7
Yes, you can create an image volume. Create a 3-D array and place the images in that array.
X = zeros(256,256,15);
X(:,:,1) = image1;
X(:,:,2) = image2;
and so on
  3 个评论
Zoe
Zoe 2017-10-28
Hi Wayne, is there a way to do it in a loop?? I have around 400 hundred matrices in my workspace and I want to store them in a 3d array. Thank you.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by