필터 지우기
필터 지우기

Files in different folders

조회 수: 1 (최근 30일)
Jenna
Jenna 2013년 5월 31일
If you have 12 different folders (that each contain pictures), is there a way to create a loop that will sum up the first images in all the folders, and the sum of the second images in all the folders, etc... for all the images?

답변 (3개)

Sean de Wolski
Sean de Wolski 2013년 5월 31일
편집: Sean de Wolski 2013년 5월 31일

Azzi Abdelmalek
Azzi Abdelmalek 2013년 5월 31일
folders={f1,f2,f3}; % your folders
for k=1:numel(folders)
f=dir([folders{k} '/*.jpg']);
files{k}={f.name};
end
for ii=1:numel(files{1});
im{ii}=0;
for jj=1:numel(files)
im{ii}=im{ii}+imread(files{jj}{ii});
end
end

Image Analyst
Image Analyst 2013년 5월 31일
You can take the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F and adapt it to use genpath() to get all subfolders.
  댓글 수: 2
Jenna
Jenna 2013년 6월 1일
My problem is that I want to read in the files using imread, which will create a matrix with data about the pixels. I also want to read in data for 135 pictures. How do I create a scenario where I will have an array of 135 x 1, where each row will actually be its own matrix of data on pixels?
Image Analyst
Image Analyst 2013년 6월 2일
If they're grayscale:
oneRow = grayImage(theRowNumber, :);
If they're color
oneRowRed = rgbImage(theRowNumber, :, 1);
oneRowGreen = rgbImage(theRowNumber, :, 2);
oneRowBlue = rgbImage(theRowNumber, :, 3);

댓글을 달려면 로그인하십시오.

카테고리

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