Block Matching Algorithm

Homework-1 | Digital Video Processing

Selahaddin HONİ

Implementation

BlockMatching() class is written in Python. It takes 5 arguments:

  • dfd : {0:MAD, 1:MSE} Displaced frame difference
  • blockSize : (sizeH,sizeW)
  • searchMethod : {0:Exhaustive, 1:Three-Step}
  • searchRange : (int) +/- pixelwise range
  • motionIntensity: True (default)
    Normalization for motion vector intensities. Assigns 255 to the largest amplitude motion vector. Also, there is a threshold that intensity value cannot be less than 100.
In main script, there are two more parameters to control the predictions:
  • predict_from_prev : False (default)
  • N : 5 (default)
    If the predictions made from previous predicted frames, anchor is updated after N frames.

Observation

In this observation, the sequential frame difference is selected as 6 to show the motion vectors better. { Anchor : 72 , Target : 78 }

Another observation here is the comparison of exhaustive search and three-step search methods. Exhaustive method is much more computationally expensive that program lasts approx. 1 second while the same program only takes 0.037 secs in fast method.

>>>Elapsed time: 0.940 secs
>>>Elapsed time: 0.037 secs

Below sample is clipped from end of the video and written as 3 frame per second, slow motion, to demonstrate how blocks are reorganized respect to motion vectors.

Video Results of Predictions made from Original Video Frames

It is clearly seen in above video samples, search range parameter takes a critical role to generate black box noise. If the actual motion in the sequence is not too fast, the search range can be decreased to suppress the noise. In the next example, search range is selected as 3.


Video Results of Predictions made from Previous Predicted Frames

Unfortunately, it is impossible to predict all other frames from only first anchor frame due to growing cumulative error. Therefore, after N frames are predicted from previous predicted frames, the reference anchor frame is updated. (N=5, in this example, again search range is 3)