How to load specific image extension from specific path directory MATLAB ?
Ältere Kommentare anzeigen
Hi. How can I load all image that has png,jpeg and jpg extension in a specific path directory by using push button ?
Someone please help me.
Antworten (1)
chandrapal Singh
am 6 Sep. 2019
0 Stimmen
Create a Pushbutton and use the following code
path=uigetdir();
path
img_directory= dir(path);
total_images= length(img_directory)-2;
total_images
for i=3:length(img_directory)
im= imread(strcat(path,'\',img_directory(i).name));
im=imresize(im, [512 512]);
out{:,:,i-2}=im;
end
3 Kommentare
Walter Roberson
am 6 Sep. 2019
Use fullfile instead of strcat
We recommend against using path as a variable name as it is an important matlab function
Walter Roberson
am 6 Sep. 2019
See also https://www.mathworks.com/matlabcentral/answers/478309-facing-difficulty-in-converting-a-matlab-function-to-c-code#comment_742361 for why using dir results that way is wrong
Najwa Samlan
am 7 Sep. 2019
Kategorien
Mehr zu Images finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!