Effacer les filtres
Effacer les filtres

adding multiple images together from a for loop

5 vues (au cours des 30 derniers jours)
Jack Sparrow
Jack Sparrow le 19 Juil 2013
I am trying to adding multiple images together into one in a for loop, but seem to only display the last image. This is what I've tried. Someone please assist me.
E = [];
for i = 1:4
str = int2str(i);
str = strcat('\',str,'.jpg');
str = strcat('C:\Users\ASUSA55V\Documents\MATLAB\images\ur3', str);
im = imread(str);
im = imresize(im,[64 70]);
E = im;
E = E+E(i);
end
imshow(E);
Thanks

Réponse acceptée

David Sanchez
David Sanchez le 19 Juil 2013
Try this out:
E = [];
for i = 1:4
str = int2str(i);
str = strcat('\',str,'.jpg');
str = strcat('C:\Users\ASUSA55V\Documents\MATLAB\images\ur3', str);
im = imread(str);
im = imresize(im,[64 70]);
E = E + im;
end
imshow(E);
  3 commentaires
Jack Sparrow
Jack Sparrow le 19 Juil 2013
Thank you david, but I'm gettin this error:
Error using +
Matrix dimensions must agree.
Error in Untitled2 (line 12)
E = E + im;
but, when I tried to change the code to
E = [];
for i = 1:4
str = int2str(i);
str = strcat('\',str,'.jpg');
str = strcat('C:\Users\ASUSA55V\Documents\MATLAB\images\ur3', str);
im = imread(str);
im = imresize(im,[64 70]);
E = im; %%%%I added this to the code
E = E + im;
end
imshow(E);
It seem to be showing only the last image. I want it to include information from all the combined images.
David Sanchez
David Sanchez le 19 Juil 2013
By the way, what do you want to do? When adding images like that, you will not save the information of the images, you'll add them up and you will end with a very white image.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Display Image dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by