0

imwriteMatlab の関数を使用して、一連の画像をフォルダーに書き込もうとしています。inputImg最初に入力画像 ( ) を与えられた行列でトリミングしcropMatrix、次にそれらの結果の画像をフォルダーに順番に保存します。私のコードは次のとおりです。

for i = 1:n
    img = imcrop(inputImg,cropMatrix);
    fileName = sprintf('C:\Users\King_Knight\Desktop\Images\%02d',i);
    imwrite ( img, 'fileName', 'jpg');
end

その後、フォルダーは完全に空になり、何も書き出されませんでした。また、Matlab ワークスペースに次のような警告メッセージが表示されました。

Warning: Escape sequence '\U' is not valid. See 'help sprintf' for valid escape sequences.

インターネットで検索しましたが、まだ解決できませんでした。誰か助けてくれませんか?ありがとう。

4

3 に答える 3

1
clear all;
%%%% Image Read
%%

input_folder  = '..'; %  Enter name of folder from which you want to upload pictures with full path
output_folder = '..';
filenames = dir(fullfile(input_folder, '*.jpg'));  % read all images with specified extention, its jpg in our case
total_images = numel(filenames);    % count total number of photos present in that folder
Outputs=total_images;
dir=output_folder;

%%

%%
for i = 1:total_images
    full_name= fullfile(input_folder, filenames(i).name);     % it will specify images names with full path and extension
    our_images = imread(full_name);                           % Read images  
    figure (i);                                               % used tat index n so old figures are not over written by new new figures
    imshow(our_images);                                       % Show all images 
    I = our_images;
    I = imresize(I, [384  384]);   

   filename = [sprintf('%03d',i) '.jpg'];
   fullname = fullfile(output_folder,'output_folder',filename);
   imwrite(I,fullname)    % Write out to a JPEG file (img1.jpg, img2.jpg, etc.)


end

%%
于 2014-11-25T11:15:08.033 に答える