View Full Version : motion mask
mathmax
8th August 2010, 14:31
Hello
I would like to apply a filter on a video but progressively, according to a mask. The less there is motion, the more the filter should be strong.
So the mask should contain black parts when there is a lot of motion in a picture and white parts when there is no or low motion.
How would you get such a mask for each picture of the video?
Thank you in advance for your help :)
PhrostByte
8th August 2010, 19:19
There is a motion-adaptive sharpener somewhere on this forum. You could probably look at that as a base for whatever you're doing.
mathmax
8th August 2010, 19:48
I don't want to sharpen but apply my custom filter. I just need to get a mask according to the motion.
PhrostByte
8th August 2010, 19:52
I meant that you could use it as a quick example.
mathmax
8th August 2010, 20:00
ok. I'll look at it, thank you :) Do you have a link?
Else, I wonder if a tool like this one could help:
http://compression.ru/video/motion_estimation/index_en.html
What do you think?
Didée
8th August 2010, 20:21
So the mask should contain black parts when there is a lot of motion in a picture and black parts when there is no or low motion.
Oh, that mask can be produced very easily!
blackness()
:):)
mathmax
8th August 2010, 21:07
does blackness() really detect motion??
PhrostByte
8th August 2010, 21:09
Oh, that mask can be produced very easily!
blackness()
:):)
hehehe
Didée
8th August 2010, 21:58
does blackness() really detect motion??
No, it doesn't. Read the letters you've typed: motion=black, no_motion=black. :)
mathmax
8th August 2010, 22:03
oh... sorry. I meant no_motion = white of course :D
Do you have an idea?
Didée
8th August 2010, 22:34
In the ten years I've been around here, the problem has come up at all times. :)
The core question is: "What is motion?"
a) motion = simple pixel difference between previous/current/next frame
weak & error prone. Noise disturbs, big motion on delicate shadings > small differences // small motion on hard edges > big difference, and-so-on. Cheap and bad.
b) motion = F( {pixel_difference}, {local_min_max} )
Method used by motion_mask of MaskTools. Somewhat more reliable than the method above, but it still has problems.
c) motion = length of motion vector as detected by a motion search
Offered by MVTools via MAnalyse + MMask. Slowest method, most reliable method.
mathmax
8th August 2010, 22:54
ok and can I get a mask using MAnalyse & MMask?
Didée
8th August 2010, 23:07
It's all written in MVtools' documentation.
source
super = source.MSuper()
backvec = super.MAnalyse(isb=true)
motionmask = source.MMask(backvec)
Precisely, this shows the motion between the current and the next frame. For previous<>current motion, use a forward-vector via "isb=false".
mathmax
9th August 2010, 18:19
Thank you. That works. :)
I just have to add the parameter kind=1 in MMask().
Didée
9th August 2010, 19:04
kind=1 ? Maybe you have to, but that's not exactly what you have asked for.
kind = 0 (default): mask represents length of vector
kind = 1: mask represents block SAD after matching
In human language:
kind=0 shows how far a block has been moved between frames(short distance vs. long distance).
kind=1 shows how different a matched block is to the reference block.
Again in other words:
kind=0 is a measure of the "amount" of motion.
kind=1 is a measure of how "good" or "bad" the blocks do match, but is not related to the amount of motion.
A big SAD can be caused by "far" motion (long vector), but that's more like a coincidence. Big SADs will also occur regularly on prominent edges, even when there actually is very little motion.
From your original question, it seems you are aiming for mode=0, not mode=1.
But of course, use whatever works best for you.
And, pssst, secret: MVTools does not detect motion. It's just a bunch of algorithms, without any cognitive imagination of the content. It only searches for things that seem to be similar. Like ... a blonde-haired child, a black-haired man, a blonde-haired man. Who is the father? MVTools' definitive answer: the blonde-haired man! But you know, that's not necessarily true ... ;)
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.