Video Display with Histogram
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Gaurav Ahuja
le 9 Juin 2017
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 commentaire
Gholamreza Jahangiri
le 4 Fév 2020
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
Voir également
Catégories
En savoir plus sur Histograms dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!