How to display the h s and v value difference in each frame of video

조회 수: 4 (최근 30일)
SHOBA MOHAN
SHOBA MOHAN 2017년 12월 19일
댓글: SHOBA MOHAN 2017년 12월 20일
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

답변 (1개)

Image Analyst
Image Analyst 2017년 12월 19일
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);

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by