CH-4 – Mean Frame Extractions – Part-3

Important Note: This article is part of the series in which discusses the theory of Video Stream Matching.

4.3.1 Algorithm 1

The Mean frame extraction process serves a dual purpose, operating in both Source and Target Videos. The mechanism remains consistent for both cases, employing the same algorithm.

This algorithm (Algorithm 1) is designed to work with videos in AVI format, focusing on the fundamental task of extracting mean frames.


  • AVI Video


  • BMP Images stored on the hard disk


  1. The algorithm takes a video and stores its first and last frames as they are on the hard drive.
  2. A defined percentage of frames (10% in this system) is extracted from the video, referred to as temporary frames.
  3. The algorithm then processes each temporary frame, calculating its histogram.
  4. The comparison of histograms is conducted using the KS Test. If two frames have the same distribution, the second one is neglected; otherwise, the second temporary frame is saved as a mean frame.
  5. This process is repeated until all frames are treated.

Algorithm Steps:

  • Step 0: Start
  • Step 1: Input a video.
  • Step 2: Store the video on the hard disk.
  • Step 3: Set the total number of frames (NumOfFrame) and define the percentage of frames to skip (TempSkip = 10%).
  • Step 4: Loop for i = 1:TempSkip:NumOfFrame
  • Step 5: Extract temporary frames from the video.
  • Step 6: Store temporary frames on the hard disk.
  • Step 7: If the loop does not end, go to Step 4.
  • Step 9: Store the first frame of the video on the hard drive.
  • Step 10: Initialize CountMeanFrame = 0.
  • Step 11: Increment CountMeanFrame by 1.
  • Steps 12-20: Perform histogram calculations and KS Test for temporary frames.
  • Step 21: If the loop does not end, go to Step 13.
  • Step 22: Store the last frame on the hard disk and increment the counter.
  • Step 23: Store in the file the number of frames selected as mean frames and their names.
  • Step 24: Stop
Ali Imran
Over the past 20+ years, I have been working as a software engineer, architect, and programmer, creating, designing, and programming various applications. My main focus has always been to achieve business goals and transform business ideas into digital reality. I have successfully solved numerous business problems and increased productivity for small businesses as well as enterprise corporations through the solutions that I created. My strong technical background and ability to work effectively in team environments make me a valuable asset to any organization.

Leave a Reply