How to display the h s and v value difference in each frame of video
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, I have calculated difference of h,s and v value of each frame in the video and want to display the value in order to random checkness of the difference value. I got final output as 360x640 matrix. Guess it displays difference value of last frame. Can anyone help me suggest the way forward.
videoObject = VideoReader(movieFullFileName)
% Determine how many frames there are.
% numberOfFrames = videoObject.NumberOfFrames;
vidHeight = videoObject.Height;
vidWidth = videoObject.Width;
for frame = 1 : numberOfFrames
% Extract the frame from the movie structure.
thisFrame = read(videoObject, frame);
% Now let's do the differencing
alpha = 0.5;
if frame == 1
Background = thisFrame;
else
% Change background slightly at each frame
% Background(t+1)=(1-alpha)*I+alpha*Background
Background = (1-alpha)* thisFrame + alpha * Background;
end
% Display the changing/adapting background.
subplot(2, 2, 3);
imshow(Background);
title('Adaptive Background', 'FontSize', fontSize);
% Do color conversion from rgb to hsv
x=rgb2hsv(thisFrame);
y=rgb2hsv(Background);
% Split the hsv component to h,s,v value
Hx = x(:,:,1);
Sx = x(:,:,2);
Vx = x(:,:,3);
Hy = y(:,:,1);
Sy = y(:,:,2);
Vy = y(:,:,3);
dh=(abs(double(Hx) - double(Hy)));
ds1=(abs(double(Sx) - double(Sy)));
dv1=(abs(double(Vx) - double(Vy)));
disp(dh);
disp(ds1);
disp(dv1);
end
end
0 Kommentare
Antworten (1)
Image Analyst
am 19 Dez. 2017
In the loop, try this:
hFig = figure; % Bring up new figure.
subplot(2,2,1);
imshow(thisFrame);
subplot(2,2,2);
imshow(dh, []);
drawnow;
subplot(2,2,3);
imshow(ds1, []);
drawnow;
subplot(2,2,4);
imshow(dv1, []);
drawnow;
promptMessage = sprintf('Do you want to Continue processing,\nor Quit processing?');
titleBarCaption = 'Continue?';
buttonText = questdlg(promptMessage, titleBarCaption, 'Continue', 'Quit', 'Continue');
if contains(buttonText, 'Quit')
close(hFig);
break;
end
close(hFig);
Siehe auch
Kategorien
Mehr zu Subplots finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!