use imwrite for images sequence

2 vues (au cours des 30 derniers jours)
Soum
Soum le 5 Fév 2014
Commenté : Image Analyst le 5 Fév 2014
Hi ;
I'm trying to save my data 'Images' after some treatment by using imwrite but the problem is
that imwrite does not work for a sequence, I've read some solutions and tried them but they
don't work this is how i wrote my code for EX:
%read the sequence
for i=1:k
%treatment
Id{k} = waverec2(t_C,L,'sym8');
fileName = sprintf('C:\\Users\\swings\\Desktop\\data\\imagesPourAlgo\\images.tiff\\%02d',k);
imwrite ( Id, 'fileName', 'tif');
end
knowing that I want to save 'write' each image separately for doing another process on them
thanks in advance

Réponse acceptée

Image Analyst
Image Analyst le 5 Fév 2014
Get rid of the {k} from ld{k}. You don't need it unless you want to keep all of the images after your for loop exits for some reason. And if you did, then you'd have to change it to ld{i} since i is the loop index, not k. k is just the stopping index and never changes.
By the say, you can use forward slashes for folder dividers, even with Windows, if that makes it simpler for you.
  3 commentaires
Soum
Soum le 5 Fév 2014
Sorry,I did a mistake I've written i instead of k it's like this %read the sequence
for k=1:37
%treatment
Id{k} = waverec2(t_C,L,'sym8');
fileName = sprintf('C:\\Users\\swings\\Desktop\\data\\imagesPourAlgo\\images.tiff\\%02d',k);
imwrite ( Id, 'fileName', 'tif');
end I used {} because I read a sequence of images from 1 to 37
Image Analyst
Image Analyst le 5 Fév 2014
You don't have to type it in again, you know. All computer have a copy and paste capability. Learn about it if you don't yet. Also, read this to learn how to format your code: http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup
But anyway, if you are going to be using your Id after your for loop exits, then you also need the {k} in the write statement:
fileName = sprintf('C:/Users/swings/Desktop/data/imagesPourAlgo/images.tiff/%02d.tif',k);
imwrite (Id{k}, fileName);
Also, don't put filename in quotes and you don't need tif if you just include an extension.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by