How to make matrix from images in folders

조회 수: 2 (최근 30일)
Kong
Kong 2020년 3월 11일
답변: Payas Bahade 2020년 3월 16일
Hello.
I want to convert images in folders to CSV file.
(name of images : weighted2, weighted3, weighted4, weighted5,,,,)

채택된 답변

Payas Bahade
Payas Bahade 2020년 3월 16일
Hi Kong,
I am assuming all images are of ‘.jpg’ format and located in same folder. If they are of different format, tweak below provided code as required.
Below mentioned code can be used for writing each image into separate CSV files:
for i=1:5
imName = strcat('weighted', num2str(i),'.jpg');
imVal = imread(imName);
fName=strcat('weightedimage',num2str(i),'.csv');
writematrix(imVal,fName);
end
And for saving images to different worksheets of a single excel file, use below mentioned code:
for i=1:5
imName = strcat('weighted', num2str(i),'.jpg');
imVal = imread(imName);
writematrix(imVal, 'weightedimages.xlsx','Sheet',i);
end
For more details, please refer imread and writematrix documentation.
Hope this helps!

추가 답변 (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