store multiple values in one variable

9 ビュー (過去 30 日間)
Siva  Sankari
Siva Sankari 2020 年 2 月 17 日
コメント済み: Siva Sankari 2020 年 2 月 17 日
dataset_folder='D:\Project\resize\';
file_name=dir(fullfile(dataset_folder,'*.jpg'));
total_images=numel(file_name);
for n=1:total_images
original=fullfile(dataset_folder, file_name(n).name);
x=imread(original);
r=x(250,250,1);
g=x(250,250,2);
b=x(250,250,3);
ph_factor =(double(g)/double(b))/double(r);
ph=sprintf('Red-%d Green-%d Blue-%d ph factor-%f',r,g,b,ph_factor);
disp(ph);
end
when i see the value of r,g,b and ph_factor only the value of last image is stored.
how can i store the values of all images for every iteration in the corresponding same variable?
Please help me

採用された回答

KSSV
KSSV 2020 年 2 月 17 日
編集済み: KSSV 2020 年 2 月 17 日
dataset_folder='D:\Project\resize\';
file_name=dir(fullfile(dataset_folder,'*.jpg'));
total_images=numel(file_name);
r = zeros(250,250,total_images) ;
g = zeros(250,250,total_images) ;
b = zeros(250,250,total_images) ;
ph_factor = zeros(250,250,total_images) ;
for n=1:total_images
original=fullfile(dataset_folder, file_name(n).name);
x=imread(original);
r(:,:,n)=x(250,250,1);
g(:,:,n)=x(250,250,2);
b(:,:,n)=x(250,250,3);
ph_factor(:,:,n) =(double(g)/double(b))/double(r);
ph=sprintf('Red-%d Green-%d Blue-%d ph factor-%f',r,g,b,ph_factor);
disp(ph);
end
  3 件のコメント
KSSV
KSSV 2020 年 2 月 17 日
Ohh..yes the loop index is n not i.....edited the answer.
Siva  Sankari
Siva Sankari 2020 年 2 月 17 日
thank u so much sir .....it worked

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by