Skip to content

7 ‐ The Effects of Filtering

Balint Laczko edited this page Sep 9, 2021 · 6 revisions

When working with the motion method, there is an option to filter the video frames after calculating the absolute difference between subsequent frames. Finding the right threshold value is crucial for accurate motion extraction. Let's see a few examples.

Example 1 | thresh=0

Here is an example of extracting the motion without any threshold. This will result in a result in which much of the background noise will be visible, including traces of keyframes if the video file has been compressed.

source = musicalgestures.MgObject('/path/to/source/video.avi', starttime=5, endtime=10, skip=0, contrast=100, brightness=20)
motiongrams = source.motiongrams(thresh=0.0)
Vertical motiongram
Horizontal motiongram
Vertical (upper) and horizontal (lower) motiongrams, no threshold filter

Example 2 | thresh=0.02

Adding just a little bit of thresholding (0.02 here) will drastically improve the final result.

Vertical motiongram
Horizontal motiongram
Vertical (upper) and horizontal (lower) motiongrams, 2% threshold filter