필터 지우기
필터 지우기

reading trivially sorted images 1 by 1 in loop

조회 수: 2 (최근 30일)
Manu Gowda
Manu Gowda 2022년 1월 26일
댓글: Manu Gowda 2022년 1월 26일
Hii, i have sorted the images in the form
Image_0001
Image_0002
..........
........... up to n
i am trying to read images one by one in a loop as follows but i am getting error because of not able to fix 0001, 0002 formate of sorting
for i=1:N % reading frames
im=imread(['C:\Users\Nikhil\Desktop\Manu Gowda\images\1mm ' num2str(i) '.jpg']);% reading images from folder
[x,g]=size(im) % x is no of rows y is no coloums
how to resolve it.

채택된 답변

Walter Roberson
Walter Roberson 2022년 1월 26일
imgdir = 'C:\Users\Nikhil\Desktop\Manu Gowda\images';
Then in the loop,
basename = sprintf('1mm%04d.jpg', i);
im = imread(fullfile(imgdir, basename));% reading images from folder

추가 답변 (1개)

KSSV
KSSV 2022년 1월 26일
편집: KSSV 2022년 1월 26일
for i = 1:10
imgName = ['image_',sprintf('%04d',i)]
end
imgName = 'image_0001'
imgName = 'image_0002'
imgName = 'image_0003'
imgName = 'image_0004'
imgName = 'image_0005'
imgName = 'image_0006'
imgName = 'image_0007'
imgName = 'image_0008'
imgName = 'image_0009'
imgName = 'image_0010'
Also you can consider using the below file exchange function:
  댓글 수: 1
Manu Gowda
Manu Gowda 2022년 1월 26일
Images are alredy named in this formate.
i want to read them one by one.

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

카테고리

Help CenterFile Exchange에서 Import, Export, and Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by