-
Notifications
You must be signed in to change notification settings - Fork 11
7 ‐ The Effects of Filtering
When working with the motion
method, there is an option to filter the video frames after calculating the absolute difference between subsequent frames.
The threshold filter basically "removes" pixels (ie. turns them to black) if their luminosity is under a defined threshold. In our implementation the thresh
parameter works in a normalized space: 0 to 1 for 0% and 100% respectively, where 100% means white.
Finding the right thresh
old value is crucial for accurate motion extraction. Let's see a few examples.
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.MgVideo('/path/to/source/video.avi', starttime=5, endtime=10, skip=0, contrast=100, brightness=20)
motiongrams = source.motiongrams(thresh=0.0)
Vertical (upper) and horizontal (lower) motiongrams, no threshold filter |
Adding just a little bit of thresholding (0.02 here) will drastically improve the final result.
Vertical (upper) and horizontal (lower) motiongrams, 2% threshold filter |
The standard threshold value (0.1) generally works well for many types of videos.
Vertical (upper) and horizontal (lower) motiongrams, 10% threshold filter |
A more extreme value (for example 0.5) will remove quite a lot of the content, but may be useful in some cases with very noisy videos.
Vertical (upper) and horizontal (lower) motiongrams, 50% threshold filter |
As the above examples have shown, choosing the thresholding value is important for the final output result. While it often works to use the default value (0.1), you may improve the result by testing different thresholds.
A project from the fourMs Lab, RITMO Centre for Interdisciplinary Studies in Rhythm, Time and Motion, Department of Musicology, University of Oslo.