how can i make a csv file from multiple tif or jpg image ??

6 次查看(过去 30 天)
for i= 1:12 file_name=['C:\Users\Lab\Desktop\xray\xray_',num2str(i),'.jpg'];
B_tmp=load(file_name);
figure(1) imagesc(B_tmp) end
csv_filename = ['C:\Users\Lab\Desktop\xray' filesep 'data.csv']; fp = fopen(csv_filename,'w'); if fp<0 uiwait(msgbox('Cannot create a new CSV file','warning','warn')); return; end
for k = 1:12 fprintf(fp,'%s,%.2f,%.2f,%.2f,%f,%f\n',filenames{k},theta(k),u_off,v_off,I_0(k),1); end
fclose(fp);
acually, i have to put imformation on iamge such as filenames{k},theta(k),u_off,v_off,I_0(k). but first, i cannot load multiple tif or jpg files :(:( could u help me?

回答(1 个)

Jan
Jan 2011-9-22
You can use a cell to store the different images:
b_tmp = cell(1, 12);
for i = 1:12
file_name = ['C:\Users\Lab\Desktop\xray\xray_',num2str(i),'.jpg'];
B_tmp{i} = imread(file_name); % Better than LOAD?!
figure(1)
imagesc(B_tmp{i})
end
I would use IMREAD instead of LOAD to read a JPG file.
Another idea would be to open the CSV file before the loop to read the images and write one line after the other. Then you do not have to keep more than 1 image at the same time in the memory.

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by