how to read images one by one from folder for operation using for loop

조회 수: 3 (최근 30일)
shital shinde
shital shinde 2020년 2월 21일
편집: Jakob B. Nielsen 2020년 2월 21일
I have dataset of natural images. And my task is to add some noise in all image and then denoise them. I cant' rename that 5600 image manually. Will anybody please tell me how to use for loop to read each image one by one from the folder without modifying name of images.

답변 (1개)

Jakob B. Nielsen
Jakob B. Nielsen 2020년 2월 21일
편집: Jakob B. Nielsen 2020년 2월 21일
I like to use the multiselect function of uigetfile as an input to a for loop:
[Names,Paths]=uigetfile({'*.img*'},'MultiSelect','on'); %or whatever file extension your images have
entirefile=fullfile(Paths,Names);
for i=1:numel(entirefile) %loop will run a number of times equal to the number of files you selected
%load your image using whichever function you prefer, by
%calling e.g. load(entirefile{i}) (note curly brackets)
%a good way to keep your workspace clean while retaining all images loaded is to load them into a structure, e.g.
imgstruc(i).raw=yourrawimage;
imgstruc(i).noised=addsomenoise
%and so on.
end

카테고리

Help CenterFile Exchange에서 Image Sequences and Batch Processing에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by