動画の平均輝度の時間プロット

14 ビュー (過去 30 日間)
Noritaka Kishi
Noritaka Kishi 2019 年 3 月 21 日
回答済み: Kenta 2019 年 3 月 23 日
aviなどの形式の動画について、全画面又はエリアを指定した上で、横軸が時間(又はフレーム)、縦軸が平均輝度のグラフを描画するにはどうすればよいでしょうか?

採用された回答

Kenta
Kenta 2019 年 3 月 23 日
%% 第一フレームの読み取り
close all;clear;clc
Video = VideoReader('shuttle.avi');
img = readFrame(Video);
figure;imshow(img)
%% 関心領域を指定(左クリックで対象の多角形を作成=>右クリック=>マスクの作成)
ROI = roipoly;
index=find(ROI==1);
close all
%% 各フレームを読み取り=>そのフレームの輝度を計算
i=1;
Video.CurrentTime=0; %1フレーム目から読み取り
int_list=zeros(1,round(Video.Duration*Video.FrameRate));
while hasFrame(Video)
img = readFrame(Video);
int=mean(img,3);
int_in_ROI=int(index);
int_list(i)=mean(int_in_ROI);
i=i+1;
end
%% グラフの表示
figure;
plot(1:i-1,int_list')
xlim([1 i-1])
xlabel('フレーム数')
ylabel('平均輝度')
title('各フレームにおけるROIの平均輝度')
roipolyでクリックしながら、対象領域を指定すれば、その領域のフレームごとの輝度が求まると思います。
各時間ごとがよければ、横軸の値にフレームレートの逆数をかけてください。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!