Save a group of processed imags output from a for loop in a specific folder

1 view (last 30 days)
Amelia on 9 Nov 2019
Commented: Amelia on 12 Nov 2019
I have an image database, i process them through a for loop, i want to save the output processed images in anther folder, i have the following error when i trying to do that:
Error using imwrite
unable to open file " ********.bmp" for writing. you might not have write permission
the code i have used is:
FileName = fullfile(savepath, sprintf(ImageName,ext));
imwrite(a, FileName);

Accepted Answer

Image Analyst
Image Analyst on 10 Nov 2019
You gave the wrong path. "savepath" is a built in function, and you're trying to call it when you call fullfile()! You should pass in SNLImagepath, not savepath. Plus you're calling sprintf() incorrectly -- you didn't give it a specification string.
Try this:
FileName = fullfile(SNLImagepath, sprintf('%s%s', ImageName,ext));
imwrite(a, FileName);
Amelia on 12 Nov 2019
Iam sorry, i didnot notice the single comma befor and after % sign, it appears that is the reason of the error i have.
Thanks again.

Sign in to comment.

More Answers (1)

Ajay Kumar
Ajay Kumar on 9 Nov 2019
Have you correctly given the permission to the folder you are writing?
Once try this,
savepath = 'C:\Some_dir\Some_folder';
FileName = fullfile(savepath, sprintf(ImageName,ext));
imwrite(a, FileName);

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by