writing a sequence of images inside a for loop using matix

2 vues (au cours des 30 derniers jours)
Jishnu C Rajan
Jishnu C Rajan le 11 Sep 2014
Commenté : Jishnu C Rajan le 12 Sep 2014
i have sequence of images formed by processing inside a for loop. I need to write them into a new folder using the concept of matrix

Réponse acceptée

Geoff Hayes
Geoff Hayes le 11 Sep 2014
Jishnu - since your code produces a new image at each iteration of the for loop, then you could do something like the following
% initialize the folder/path
folderToSaveImg = '/Users/myName/someDirectory/images';
% do your loop
for k=1:100
% do the processing to create the image named img
img = randi(255,100,100,3); % example only
% create the file name
fileName = sprintf('image%d.mat',k);
% join the file name to the folder name
fileDestination = fullfile(folderToSaveImg, fileName);
% save the image as a matrix
save(fileDestination,'img');
end
The above code (example only) will save 100 images from the sequence to individual mat files where the data stored in the file is a three dimensional matrix.
  4 commentaires
Image Analyst
Image Analyst le 11 Sep 2014
Jishnu, your comment seems to indicate that you think an image and a matrix are different things. Why is that? In MATLAB, an image is a matrix, so you don't need 2 things: an image and some separate matrix. They are one and the same.
Jishnu C Rajan
Jishnu C Rajan le 12 Sep 2014
thanks alot

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by