Clear Filters
Clear Filters

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

2 views (last 30 days)
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);

Accepted Answer

Star Strider
Star Strider on 19 Jul 2020
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 Comments
a.s
a.s on 4 Aug 2020
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 on 4 Aug 2020
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.

Sign in to comment.

More Answers (0)

Categories

Find more on File Operations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!