How to count the frequency of flashing light in a video

Hi, I have a video-file, rgb, format avi, dimension 62x62, rate 60fps. duration 1min. The event is a flashing red light otherwise dark.
The flashing frequency very from video to video. So I wonder if someone could suggest me how to count the frequency using image-processing or video-processing tool box.
Thank you in advance for your attention
Emerson

1 Comment

hello emerson were you able to get the exact value of the frequency??

Sign in to comment.

 Accepted Answer

Cedric Wannaz posted this code to do just that about a year ago. You can probably adapt it to your application.

5 Comments

Thank you Star Strider, I used the script below:
% vidObj = VideoReader( 'Ghost.mp4' ) ; % Attached to my post.
vidObj = VideoReader( '1.avi' ) ;
nFrames = vidObj.NumberOfFrames ;
tFrame = (1:nFrames) / vidObj.FrameRate ;
ghostCom = zeros( nFrames, 1 ) ;
for fId = 1 : nFrames
grayImage = rgb2gray( read( vidObj, fId )) ;
ghostCom(fId) = sum( grayImage(:) ) ;
end
figure() ; clf ;
set( gcf, 'Color', 'White', 'Units', 'Normalized', ...
'OuterPosition', [0, 0.1, 1, 0.6] ) ;
plot( tFrame, ghostCom/max(ghostCom), 'b' ) ;
set( gca, 'YTick', [0, 1] ) ;
xlabel( 'Time [s]' ) ;
And added the following lines to obtain directly the frequency:
[r] =risetime(ghostCom);
FREQUENCY =numel(r)/60;
Thus, problem solved. Thank you again for your suggestion
Emerson
My pleasure!
The credit actually goes to Cedric. I just remembered that he wrote it, then went searching for it.
Hi, does anyone know what computer algorithm used in this research https://advances.sciencemag.org/content/6/36/eabd3083 i really need the algorithm for our own research and im still new in this software.
Thank you in advance
Luke Abellanosa —
I just now looked through the Supplements, and (as you already discovered) neither the code nor the algorithm is published. You’d likely have to write to the authors, however I doubt they’d currently be forthcoming with the information.
Note that in the Acknowledgements section:
  • Competing interests: A U.S. provisional patent application has been filed by Duke University on 12 June 2020. The authors of the current manuscript are identical to the inventors on the patent application. The patent information is as follows: Title: “Optical Method to Test Efficacy of Face Masks”; inventors: M.C.F., E.P.F., D.G., W.S.W., I.H., and E.W.; application number: 63/038331.
Since they’re applying for a U.S. patent (and likely foreign patents) on this technique, that information will not be available until the patent is granted (typically about four years after the application is filed).
In the interim, see if anything in the Image Processing Toolbox — Examples documentation section has anything you can use to build on. (I have done some medical image processing, however it is not an area of my expertise, so I likely cannot help you with it.)
hello again can i ask if what are to be edited in this script depending on the properties of the video im still a beginner to this
vidObj = VideoReader( '1.avi' ) ;
nFrames = vidObj.NumberOfFrames ;
tFrame = (1:nFrames) / vidObj.FrameRate ;
ghostCom = zeros( nFrames, 1 ) ;
for fId = 1 : nFrames
grayImage = rgb2gray( read( vidObj, fId )) ;
ghostCom(fId) = sum( grayImage(:) ) ;
end
figure() ; clf ;
set( gcf, 'Color', 'White', 'Units', 'Normalized', ...
'OuterPosition', [0, 0.1, 1, 0.6] ) ;
plot( tFrame, ghostCom/max(ghostCom), 'b' ) ;
set( gca, 'YTick', [0, 1] ) ;
xlabel( 'Time [s]' ) ;
[r] =risetime(ghostCom);
FREQUENCY =numel(r)/60;

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!