i have 20 images saved in a folder in computer now i have to convert to gray images at the time. how to convert rgb to gray ?
2 views (last 30 days)
Wanbin Song on 28 Oct 2015
Supposed that your images are named as image1.png, image2.png, ... image20.png.
You can do it as follows:
for i = 1:20
img_str = sprintf('image%d.png', i);
temp_gray = rgb2gray(imread(img_str));
img_str = sprintf('gray_image%d.png', i);
Then, converted gray images will be stored in the path as name with 'gray_imgXX.png'.