How to access images(like Image1,Image2...)from a folder and pass through a code in Matlab?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am doing my final year project. I have done a program to capture images and store it in a perticular folder(here it is FinalProject). I named those pictures like Image1,Image2,Image3..etc. Now i have written a programm to access the images one by one (like Iage1,Image2,Image3...etc). But it shows some errors. Please help me by retifying my code or put another solution. If any kind hearted person do that i will be thankfull to him /her.I have to submit my project at the end of third week of May,2022. I put my code. ThankYou.
for i=1:3
ImageFolder ='C:\Users\User\Desktop\FinalProject';
imgName = [ImageFolder,'\Image_',num2str(i),'.jpg'];
input_image = imread('C:\Users\User\Desktop\FinalProject\'\Image%d',num2str(i)','.jpg'');
imshow(input_image)
end
Here its error:
Error: File: unknown.m Line: 4 Column: 95
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched
delimiters.
0 Kommentare
Akzeptierte Antwort
Jonas
am 3 Mai 2022
the path creation is a mixture of multiple principles, one possibility is
imread(['C:\Users\User\Desktop\FinalProject\Image',num2str(i),'.jpg']);
Weitere Antworten (1)
DGM
am 3 Mai 2022
You created a variable called imgName, but you're not using it.
input_image = imread(imgName,'.jpg');
Of course, since this loop displays each image with imshow() without pausing, you'll only see the last one. Only the last image will remain in memory, since input_image is overwritten each time.
You can preallocate a cell array or something and then load the images into a cell array instead.
numpicts = 3;
imagepile = cell(numpicts,1);
for k = 1:numpicts
ImageFolder ='C:\Users\User\Desktop\FinalProject';
imgName = [ImageFolder,'\Image_',num2str(k),'.jpg'];
imagepile{k} = imread(imgName,'.jpg');
end
montage(imagepile)
Siehe auch
Kategorien
Mehr zu Image Data Workflows finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!