Video Display with Histogram

2 ビュー (過去 30 日間)
Veilchen1900
Veilchen1900 2017 年 6 月 6 日
Hi,
I want to run at the left side of my figure a video and to show at the right side the corresponding live histogram. First of all, is this possible in Matlab?
I have a code to run the video and one to display the histograms. But it didn't work together. Thanks in advance for every hint!
First code:
% Display video
v = VideoReader('myVideo.avi');
ii = 1;
while hasFrame(v)
mov(ii) = im2frame(readFrame(v));
ii = ii+1;
end
movie(gcf,mov)
Second code:
% Display histograms
v = VideoReader('myVideo.avi');
while hasFrame(v)
thisFrame= readFrame(v); % Get one RGB frame of the color video.
redChannel = thisFrame(:,:,1); % Extract red channel only.
[pixelCounts, grayLevels] = imhist(redChannel); % Get histogram of red channel.
figure(1), subplot (1,2,2),stem(grayLevels, pixelCounts);
end

回答 (1 件)

Gaurav Ahuja
Gaurav Ahuja 2017 年 6 月 9 日
I think this should help.
if true
v = VideoReader('SampleVideo_640x360_1mb.mp4');
ii = 1;
while hasFrame(v)
f= readFrame(v);
mov(ii) = im2frame(f);
ii = ii+1;
subplot (1,2,1)
imshow (f)
thisFrame= f; % Get one RGB frame of the color video.
redChannel = thisFrame(:,:,1); % Extract red channel only.
[pixelCounts, grayLevels] = imhist(redChannel); % Get histogram of red channel.
figure(1), subplot (1,2,2),stem(grayLevels, pixelCounts);
drawnow;
end
end
  1 件のコメント
Gholamreza Jahangiri
Gholamreza Jahangiri 2020 年 2 月 4 日
Hi,
I need this code with some modifiation. I want to make each frame to gray scale, and then get the minimum value for each pixel in the video and build a hisogram to apply that histogram to the video. So, I have a video with no changing in brighness, just need the movements of pixels.
Thanks
Reza

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by