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 ?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 ?
0 comentarios
Respuestas (1)
Wanbin Song
el 28 de Oct. de 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);
imwrite(temp_gray, img_str);
end
Then, converted gray images will be stored in the path as name with 'gray_imgXX.png'.
2 comentarios
rohit ranjan
el 28 de Oct. de 2015
Editada: Walter Roberson
el 2 de Nov. de 2015
Wanbin Song
el 2 de Nov. de 2015
Is your code could read images correctly and displays it?
I don't think so, but if so, you just add the command 'rgb2gray'.
Ver también
Categorías
Más información sobre Convert Image Type en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!