Carolina Rickenstorff
Carolina Rickenstorff

Reputation: 49

importing multiple images matlab

I have a set of 100 jpg images named consecutively and I want to add them up to get a single image. I have seen the answer from here, but it does not run with me, what happened?

Here is the code:

im = imread('C:\Documents and Settings\1026175117_1.jpg');
for i = 2:10
im = imadd(im,imread(sprintf('C:\Documents and Settings\1026175117_%d.jpg',i)));
end
im = im/1000;
imshow(im,[]); 

Here's the error message:

Error using ==> imread
Can't open file "C:" for reading;
you may not have read permission.

Upvotes: 3

Views: 2058

Answers (1)

John Colby
John Colby

Reputation: 22588

Backslash is a special character for sprintf() and needs to be escaped. Either use "\\" instead of "\" or try constructing your file paths another way. fullfile() is a good way to do it, so you only have to use sprintf for the file name part. Also see help sprintf.

Upvotes: 3

Related Questions