Clear Filters
Clear Filters

処理をして得られたデ​ータを表にして、エク​セルに出力する方法

6 views (last 30 days)
suzuka iwaki
suzuka iwaki on 27 Oct 2023
Answered: Dyuman Joshi on 27 Oct 2023
jpegFiles = dir('*.jpg');
numfiles = 162;
mydata = cell(1, numfiles);
for k = 1:numfiles
mydata{k} = imread(jpegFiles(k).name);
RGB = imread(jpegFiles(k).name);
I = im2gray(RGB);
graying = rgb2gray(RGB);
meanLuminance = mean(graying,"all"); % RGBをグレースケールに変換したときの平均輝度
end
1行目に、番号、平均輝度のラベルを含ませた、163行2列の表で表したいと考えています。分からない点が2つあり、上のコードで得られた、変数である平均輝度をデータセットとしてテーブルに読み込む方法と、1から162番までの162行をいかにして作るかというところです。よろしくお願いします。

Answers (1)

Dyuman Joshi
Dyuman Joshi on 27 Oct 2023
From what I understood -
jpegFiles = dir('*.jpg');
numfiles = 162;
mydata = cell(1, numfiles);
%Preallocate a table
T = table((1:162)', zeros(162,1), 'VariableNames', {'Serial_No.', 'Average_Luminance_Value'})
for k = 1:numfiles
mydata{k} = imread(jpegFiles(k).name);
RGB = imread(jpegFiles(k).name);
%I = im2gray(RGB);
graying = rgb2gray(RGB);
meanLuminance = mean(graying,"all"); % RGBをグレースケールに変換したときの平均輝度
T{k,2} = meanLuminance;
end

Categories

Find more on table in Help Center and File Exchange

Tags

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!