I tried the following program for reading multiple images(about 300 images). Now I want to store these images immediately after reading each to some location by some name as
I highly recommend that you store them in a cell array:
for k=1:5
image_path = ['C:\Users\shree\Desktop\1\im' num2str(i) '.jpg']; %// I have moved this to be on its own line as it will make debugging easier. You don't have to, but I think it's a good idea.
images_all{k} = imread(image_path);
end
By using eval
to create variable names like g1
, g2
etc you pollute your workspace with an unmanageable amount of variables. Plus if they are all in a cell array then it's really easy to apply the same function to each of them either in a loop or with cellfun
.
For example if you want to convert them all to greyscale now:
images_grey = cellfun(@rgb2gray, images_all, 'UniformOutput', false);