Video Display with Histogram
조회 수: 3 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (1개)
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
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 Exchange에서 Histograms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!