Read image and save it using imwrite?
显示 更早的评论
Hello! I read pictures using imread and then try to write it to folder c:\result. The name of the images should be same than readed image, but I like to add index and remove part of the name. So I read image image00123_big.bmp and I like to save image to name image00123_small_'index_number'.bmp. How can I do that?
采纳的回答
更多回答(1 个)
Alessandro
2013-3-14
编辑:Alessandro
2013-3-15
id = 5;
folder = 'c:\result\'
newimagename = [folder 'image00123_small_' num2str(id) '.bmp'];
imwrite(image,newimagename)
4 个评论
Teemu
2013-3-14
Alessandro
2013-3-14
编辑:Alessandro
2013-3-15
strid = regexp(readimagename,'\d','match')
id = str2num(strid(1));
folder = 'c:\result\'
newimagename = [folder 'image00123_small_' num2str(id) '.bmp'];
imwrite(image,newimagename)
Jan
2013-3-14
Do not shadow the important Matlab function path by a local variable. This can leed to very strange effects e.g. during debugging.
Image Analyst
2013-3-14
Use "folder" instead of "path" for a variable name. Don't use "dir" either - it's a built in function.
类别
在 帮助中心 和 File Exchange 中查找有关 Convert Image Type 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!