フィルターのクリア

how to store many result in csv file in a row ?

1 回表示 (過去 30 日間)
sumu nowshin
sumu nowshin 2018 年 8 月 7 日
編集済み: Jan 2018 年 8 月 9 日
I have 20+ images in a folder and want to store their feature result in CSV file. here is my code :
srcFiles = dir('D:\study\iccit_confr\mono\*.jpg'); % the folder in which ur images exists
for i = 1 : length(srcFiles)
filename = strcat('D:\study\iccit_confr\mono\',srcFiles(i).name);
I = imread(filename);
%figure, imshow(I);
I2 = imcrop(I);
figure, imshow(I2)
u=lbp(I2);
disp(u)
csvwrite('test.csv',u)
end
I have LBP function file. By this code only last result stored in CSV file. plz, help by giving a code for solving this.

採用された回答

Stephen23
Stephen23 2018 年 8 月 7 日
編集済み: Stephen23 2018 年 8 月 7 日
You need to change the filename for each loop iteration, e.g.:
fnm = sprintf('test_%04d.csv',i);
csvwrite(fnm,u)
Otherwise you are simply overwriting the same file on each iteration.
  3 件のコメント
Stephen23
Stephen23 2018 年 8 月 7 日
編集済み: Stephen23 2018 年 8 月 7 日
@sumu nowshin: the easiest way would probably be to write the file using fprintf. You can easily define the format string to be the required length (use repmat) and add newlines when required. Simply open the file and keep appending the data!
Alternatively you could try using save(...,'-ascii','-append'), which according to the save documentation "For ASCII files, '-append' adds data to the end of the file." I have never tried this.
sumu nowshin
sumu nowshin 2018 年 8 月 7 日
Thank u so much @Stephen Cobeldick.For my research work, I need to store feature values of blood cell images in a CSV file

サインインしてコメントする。

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by