How to save a figure with three - digit numbers or Time Stamps in folder

2 次查看(过去 30 天)
Hi, I want to save a figure of video in a folder (this frame grab on which color recognition processing has been done and frame name is img1.) and then order to besorted in the same folder in terms of order - digit numbers or Time Stamps.I already apologize that my english is not strong enough .
imwrite(img1,'orginimage.png');
for k=1:10;
img =img1;
baseFileName = sprintf('G:\abcd\rafe evejaj\pic%03d.png', k);
fullFileName = fullfile(baseFileName);
imwrite(img, fullFileName);
end
__________________________________________________________________---
> Error using imwrite (line 433)
Unable to determine the file format from the file name.
> Error in lkjhgfd2 (line 183)
imwrite(img, fullFileName);

采纳的回答

Star Strider
Star Strider 2020-7-19
In order to print a backslant (\) character using sprintf (or its friends), it is necessary to ‘escape’ it by preceding it with a backslant character.
Try this:
baseFileName = sprintf('G:\\abcd\\rafe evejaj\\pic%03d.png', k);
.
  6 个评论
a.s
a.s 2020-8-4
hi,
Now the problem I have is that an image has been repeated several times and has been saved in three digit number , and every time the run is processed , the new photo replaces the previous shots .
My program is that when the program is run and the screenshot is taken from the video(for example 10 times) then the video stops and then the program is run again and The program runs this way up to 20 times.
I want the photos to be saved in order in all these steps and not to be replaced.
thank you for your help.
Star Strider
Star Strider 2020-8-4
I am not certain what the problem actually is.
One option is to include a date (and time) or other uniquely identifying information along with the serial identification number. That simply requires an additional field in the sprintf format string, and that the additional information be supplied as an argument to the sprintf call.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 File Operations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by