MATLAB Answers

0

How to conver folder (images) from GRB to Gary and save them in Output folder with the same original names?

Asked by Goma Najah on 7 Aug 2016
Latest activity Answered by Image Analyst
on 7 Aug 2016
i have this code which convert image to Gray and save it in current folder.
directory = dir('AM01AFS.jpg');
for i = 1 : size(directory,1)
filename = directory(i).name;
img = rgb2gray(imread(filename));
imwrite(img, ['Gr_' filename]);
end
I need to convert folder (images) from GRB to Gary and save them in Output folder with the same original names? Any help Plz.

  0 Comments

Sign in to comment.

1 Answer

Answer by Image Analyst
on 7 Aug 2016
 Accepted Answer

You need to use fullfile() to make a name with the output folder prefixing the base file name:
outputFileName = fullfile(outputFolder, filename);
imwrite(img, outputFileName);

  0 Comments

Sign in to comment.