error using imwrite which gives Can't open file "1.jpg" for writing. You may not have write permission.

1 view (last 30 days)
my program is as follows
clc; close all; clear all;
myVid= VideoReader('BS.avi');
numFrames= myVid.NumberOfFrames;
i= 1;
while i<=numFrames
currentFrame= read(myVid,i);
combinedString=strcat(int2str(i),'.jpg');
imwrite(currentFrame,combinedString);
i=i+1;
end
  1 Comment
Geoff Hayes
Geoff Hayes on 25 Oct 2014
You will need to verify that you have permissions to write files to the current directory. Just prior to running your program, type the following in the Command Window
fileattrib
What does the UserWrite field show?

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 25 Oct 2014
Edited: Image Analyst on 25 Oct 2014
What folder does it say when you issue this command just before your loop"
pwd
It looks like you want to extract all the frames of a video into separate image files. That is exactly what my attached demo do. Simply change the file name and use it. The second half rebuilds a video from the separate frames. You can remove that part if you want.

Community Treasure Hunt

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

Start Hunting!