use imwrite for images sequence

6 次查看(过去 30 天)
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

采纳的回答

Image Analyst
Image Analyst 2014-2-5
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 个评论
Soum
Soum 2014-2-5
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 2014-2-5
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Convert Image Type 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by