save more than one image in a matfile

i select an image from a folder and save it in a matfile..... then i load the matfile and display the image.....
[filename pathname]=uigetfile('*.tif','Select An Image');
inputImage=imread([pathname filename]);
save imageMatfile inputImage
how to save more than one image in the same matfile(not all images in folder, but only those i want).......using these select statements is it possible???...... please do reply....

 Accepted Answer

for K = 1 : 10
[filename pathname] = uigetfile('*.tif','Select An Image');
inputImages{K} = imread(fullfile(pathname, filename));
end
save imageMatfile inputImages

4 Comments

Elysi Cochin
Elysi Cochin on 4 Feb 2013
Edited: Elysi Cochin on 4 Feb 2013
sir is it possible to save into matfile without using for loop....because i want output as.... each time i execute the mainfile and select an image.... i want to append it to the end of matfile....its not selecting 10 images in one execution..... each time i execute i select one image..... is it possible sir.... and sir how to display these images from matfile into a figure.....
will "append" work.... but sir i dont know the syntax for append.... please do reply sir.....
Whenever you do not know the syntax of a command, simply look at the documentation: help save and doc save.
If you have a new enough version of MATLAB, you can use matfile() to store additional array elements into an array stored in a .mat file.
You can use -append to store additional information into a .mat file, but you need to use a different variable name each time or else the existing content with that variable name will get overwritten.

Sign in to comment.

More Answers (1)

Saving your first image
im1={imread('first_image')}
save yourfile im1
Adding a new image
im1=imread('news_image')
im=load('yourfile')
im1=im.im1
im1{end+1}
save yourfile im1

4 Comments

how can i display, each of the images in a different figure from this matfile.... please do reply....
im=load('yourfile')
im1=im.im1
for k=1:numel(im1)
figure
imshow(im1{k})
end
sir but i'm getting this error...
??? Cell contents reference from a non-cell array object.
Error in ==> Untitled at 19
imshow(im1{k})
Have you used?
im=load('yourfile')
and when saving the first image
im1={imread('first_image')}

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!