From: Aydos R on 8 Jun 2010 06:38 hi there, I have a dataset including "jpg" files... data/ model 1.jpg model 2.jpg .. .. model 30.jpg and I would like to read all the images by using "imread" function... but instead of coding like ; img1=imread('./data/model 1.jpg'); img2=imread('./data/model 2.jpg'); .. .. img30=imread('./data/model 30.jpg'); I would like to do it by "for" cycle...for example; for i=1:30 img(i)=imread('./data/model (i).jpg'); end and after applying some image processing steps I would like to save the images to another directory.For example ; imwrite(img1edited,'./editeddata/editedmodel 1.jpg'); imwrite(img2edited,'./editeddata/editedmodel 2.jpg'); .. .. imwrite(img30edited,'./editeddata/editedmodel30.jpg'); same as "imread" process,I would like to do it by "for" cycle..like; for i=1:30 imwrite(img(i)edited,'./editeddata/editedmodel (i).jpg'); end but I do not know how to do it..Can anyone help me,please? thanks
From: ImageAnalyst on 8 Jun 2010 06:47 Use dir() to get the filenames. Use sprintf() to make up new filenames. Review the FAQ for more handy tidbits of information: http://matlabwiki.mathworks.com/MATLAB_FAQ
From: Aydos R on 8 Jun 2010 09:09 a=dir('./data/*.jpg') for i=1:30; c=imread(a(i).name); d=edge(c,'canny'); imwrite(d,'./editeddata/','editedmodel',strcat(i),'.jpg'); end Reading part is OK...But,I still have some problems about writing... After the process I would like to see that folder and files... /editeddata editedmodel 1.jpg editedmodel 2.jpg .. .. editedmodel 30.jpg I know this line is wrong but how can I fix it; imwrite(d,'./editeddata/','editedmodel,'strcat(i),'.jpg'); thanks
From: Walter Roberson on 8 Jun 2010 09:23 Aydos R wrote: > a=dir('./data/*.jpg') > for i=1:30; > c=imread(a(i).name); > d=edge(c,'canny'); > imwrite(d,'./editeddata/','editedmodel',strcat(i),'.jpg'); > end strcat() does not format an integer as a string. imwrite(d, sprintf('./editeddata/editedmodel/%d.jpg', i));
|
Pages: 1 Prev: int16 to float conversion..help Next: SimPowerSystems sources |