imwrite "the filename must be provided issue"

2 ビュー (過去 30 日間)
Jishnu Murali Thampan
Jishnu Murali Thampan 2020 年 1 月 25 日
回答済み: Image Analyst 2020 年 1 月 25 日
Hi ,
I am trying to read a video file and store the frames in a folder . The imwrite is giving me a "a filename must be provided error".This is my program:
filename = [sprintf("%03d L",ii) '.jpg'];
fullname = fullfile(workingDir,'images',filename);
imwrite(leftone,fullname) ;
Please help
  2 件のコメント
Mohammad Sami
Mohammad Sami 2020 年 1 月 25 日
your filename assignment is creating two strings.
you can replace it with the following
filename = sprintf('%03d L.jpg',ii);
Image Analyst
Image Analyst 2020 年 1 月 25 日
Can you make this an answer? That way you can earn reputation points for it, unlike up here in the section which is used to ask posters for additional information.

サインインしてコメントする。

回答 (1 件)

Image Analyst
Image Analyst 2020 年 1 月 25 日
The problem is you used double quotes in the first part and single quotes in the second part which make two strings. Try this corrected code:
% Initialize some variables.
leftone = imread('cameraman.tif');
ii = 1
workingDir = pwd; % The current folder.
% Now Jishnu's code, corrected and made more robust.
outputFolder = fullfile(workingDir, '/images');
if ~isfolder(outputFolder)
mkdir(outputFolder);
end
baseFileName = sprintf('%03d L.jpg',ii)
fullFileName = fullfile(outputFolder,baseFileName)
imwrite(leftone, fullFileName);

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by