How to index filenames correctly?

4 views (last 30 days)
Please help if you have the answer.
I have .png images, which I want to read randomly and send to a function which will perform segmentation and then output the answer in a xls file or csv... But I doing the indexing in the beginning wrong. Here is what I want to do.
store files in Images:
Images=['image001.png'; 'image003.png'; 'image020.png';'image022.png';'image024.png';'image025.png'; 'image026.png';'image027.png';'image028.png';'image029.png';
'image035.png';'image036.png';'image038.png';'image042.png']
Then by choice have the index as follow:
Items=[1 2 5 6 9 12];
I want the 1st, the 2nd, 5th etc...
Then run a loop
for k=1:size(Items,1)
[A,n] = Calc_Exudate(Images(Items(k)));
%append A n to xls or csv
dlmwrite('data.csv',[mat2str(A') ',' num2str(n)],'delimiter',',','-append');
end
With this code it select "i", because that is the 1st letter, but I want the whole file/item.

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 31 Aug 2013
Edited: Azzi Abdelmalek on 31 Aug 2013
Use
[A,n] = Calc_Exudate(Images(Items(k),:));
% or use a cell array
Images={'image001.png';'image003.png';'image020.png';'image022.png'}
[A,n] = Calc_Exudate(Images{Items(k)});

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!