How to save all jpg data after preprocessing into workspace?

4 ビュー (過去 30 日間)
Ou Jin Sheng
Ou Jin Sheng 2021 年 11 月 5 日
コメント済み: Ou Jin Sheng 2021 年 11 月 6 日
%% preprocess
%Ou Jin Sheng
%B041820063
clc ;
clear;
home;
%loading file
filelist = dir('*.jpg');
L = length(filelist);
for i = 1:60
CurrentImage{i} =imread([ num2str(i) '.jpg']);%read image based
%%code here
%%implement preprocessed image onto current image
Complete_Output{i} = CurrentImage{i} + FinalOutput;
%%Write complete_output into workspace
imwrite(Complete_Output, {i}); %error here
end
Currently i am reading 60images from local files, after preprocessing, i need to save all 60 images into ...
workspace, how can i do it? Please advice. Much appreciate.

採用された回答

Geoff Hayes
Geoff Hayes 2021 年 11 月 5 日
@Ou Jin Sheng - imwrite writes data to a file as
imwrite(dataArrayOrMatrix, 'filename')
Your code is doing something different
imwrite(Complete_Output, {i}); %error here
I suspect that you want to do something like
imwrite(Complete_Output{i}, sprintf('updatedImage%d.jpg',i));
or something similar to write the updated image to file (not the workspace).
  1 件のコメント
Ou Jin Sheng
Ou Jin Sheng 2021 年 11 月 6 日
Thank you @Geoff Hayes, It works for me. Just that it write to file.

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

その他の回答 (1 件)

yanqi liu
yanqi liu 2021 年 11 月 6 日
編集済み: yanqi liu 2021 年 11 月 6 日
clc ;
clear all;
home;
%loading file
filelist = dir('*.jpg');
L = length(filelist);
for i = 1:60
CurrentImage{i} =imread([ num2str(i) '.jpg']);%read image based
%%code here
%%implement preprocessed image onto current image
Complete_Output{i} = CurrentImage{i} + FinalOutput;
%%Write complete_output into workspace
%imwrite(Complete_Output, {i}); %error here
imwrite(mat2gray(Complete_Output{i}), sprintf('./%03d.png', i));
end

カテゴリ

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

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by