How to analyse optical flow information

24 vues (au cours des 30 derniers jours)
Life is Wonderful le 2 Août 2023
Commenté : Life is Wonderful le 24 Août 2023
Hi there,
I have acquired the output from the optical fow in a structure and would like to learn how to use the data to say there are defects - using magnitude and Orientation, as well as how to use Vector motion Vx and Vy in my analysis.As an example, consider determining the peak and obtaining the wavelength measurement per unit time.
Is it possible to extract the output vectors? I'd like to use static analysis to determine the quality in terms of flicker, blink, and blur. Any suggestions would be highly appreciated.
The information in my sample data structure is as follows:
Vx: [360×640 single]
Vy: [360×640 single]
Orientation: [360×640 single]
Magnitude: [360×640 single]
3 commentairesAfficher 1 commentaire plus ancienMasquer 1 commentaire plus ancien
Life is Wonderful le 3 Août 2023
Modifié(e) : Life is Wonderful le 3 Août 2023
Sure, please accept my apologies. I am using code that is mostly available in the example paper. It would be great if you could offer your thoughts on how to proceed with the problem stated above.
opticFlow = opticalFlowHS
h = figure;
movegui(h);
hViewPanel = uipanel(h,'Position',[0 0 1 1],'Title','Plot of Optical Flow Vectors');
hPlot = axes(hViewPanel);
fprintf('%15s| %15s| %15s| %15s|\n---------------+----------------+----------------+-----------------+\n', ...
'VidCurrentTime','Magnitude','Orientation','Algexecutiontime' );
frameGray = im2gray(frameRGB);
t1 =tic;
flow = estimateFlow(opticFlow,frameGray);
t2 = toc(t1);
imshow(frameRGB)
hold on
plot(flow,'DecimationFactor',[5 5],'ScaleFactor',60,'Parent',hPlot);
q = findobj(gca,'type','Quiver');
% Change the color of the arrows to red
q.Color = 'r';
drawnow
hold off
pause(10^-3)
end
Life is Wonderful le 8 Août 2023
Could you please show me how to use the above code to generate spatial image gradients in grey levels per pixel and temporal gradients in grey levels per frame and export the results?
Thank you very much

Connectez-vous pour commenter.

Réponse acceptée

Praveen Reddy le 23 Août 2023
Modifié(e) : Praveen Reddy le 23 Août 2023
Hi,
I understand that you want to compute spatial image gradients, temporal gradients and export the results. You can compute the spatial gradient using the flow obtained and temporal gradient as the difference between current frame and previous frame. Please find the modified code below where the results are exported as “.mat” files.
opticFlow = opticalFlowHS;
h = figure;
movegui(h);
hViewPanel = uipanel(h,'Position',[0 0 1 1],'Title','Plot of Optical Flow Vectors');
hPlot = axes(hViewPanel);
% Create arrays to store spatial and temporal gradients
fprintf('%15s| %15s| %15s| %15s|\n---------------+----------------+----------------+-----------------+\n', ...
'VidCurrentTime','Magnitude','Orientation','Algexecutiontime' );
% Initialize previous frame variables
prevFrameGray = im2gray(prevFrameRGB);
frameGray = im2gray(frameRGB);
t1 = tic;
flow = estimateFlow(opticFlow,frameGray);
t2 = toc(t1);
% Calculate spatial gradient (per pixel) using the magnitude of flow
% Calculate temporal gradient (per frame) using the difference between current and previous frame
imshow(frameRGB)
hold on
plot(flow,'DecimationFactor',[5 5],'ScaleFactor',60,'Parent',hPlot);
q = findobj(gca,'type','Quiver');
q.Color = 'r';
drawnow
hold off
pause(10^-3)
% Store current frame for the next iteration
prevFrameRGB = frameRGB;
prevFrameGray = frameGray;
end
% Export the spatial and temporal gradients as data files
I hope this helps.
1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
Life is Wonderful le 24 Août 2023
could you kindly advise on how to rotate the angular component for both temporal and spatial gradients?
I am really grateful.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Tracking and Motion Estimation dans Help Center et File Exchange

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by