View Full Version : Mask creation for estimation quality motion compensation (MVTools & mt_masktools)
Hi folk!
AVISource("seldv2.avi")
AssumeBFF()
ConvertToYV12(interlaced=true)
fields=SeparateFields()
bv1 = fields.MVAnalyse(blksize=8, isb = true, truemotion=true, search=2, delta = 2, idx = 1, overlap=4,chroma=false)
mb1=Greyscale(fields).MVMask(bv1,kind=1,ml=150,Ysc=255)
mb1b=mt_binarize(mb1,threshold=254,upper=true)
I want get mask mb1b could be equal 0 at good motion estimation and 255 at ml>=150. It is right? Which color correspond mask value when I see on display?
With kind regards yup.
See Image!
http://img210.imageshack.us/img210/5520/maskcree6.th.png (http://img210.imageshack.us/my.php?image=maskcree6.png)
script
AVISource("flower.avi")
AssumeBFF()
ConvertToYV12(interlaced=true)
fields=SeparateFields()
bv1 = fields.MVAnalyse(blksize=8, isb = true, truemotion=true, search=2, delta = 2, idx = 1, overlap=4,chroma=false)
mb1=Greyscale(fields).MVMask(bv1,kind=1,ml=150,Ysc=255)
mb1b=mt_binarize(mb1,threshold=254,upper=true)
StackVertical(mb1b,mb1)
Why I see different collors on binary mask, could be 0 or 255.
yup.
gzarkadas
4th June 2008, 17:57
Try changing the last line before StackVertical to:
...
mb1b=mt_binarize(mb1,threshold=254,upper=true, u=2, v=2)
...
gzarkadas :thanks:
I try this no success. I use last version http://manao4.free.fr/masktools-v2.0a35.zip.
yup.
gzarkadas
4th June 2008, 19:52
Yes, I tested it (now, not before :)). You need to put -128 (or -127, I am not sure; but both work for your example) instead of 2 for u,v arguments, like this:
mb1b=mt_binarize(mb1,threshold=254,upper=true, u=-128, v=-128)
Note: with 254 as threshold the mask turned completely white on your sample picture; you may need to reduce your threshold value.
Didée
4th June 2008, 19:53
First step, first pitfall ... second step, second pitfall ...
mb1 = Greyscale(fields).MVMask(bv1,kind=1,ml=150,Ysc=255)
Greyscale is without effect here. The clip argument to MVMask is only a dummy that doesn't influence the result. You could as well use BlankClip(fields).MVMask(..), the result will be the same.
MVMask delivers result on all three planes Y, U, V. Output of U,V planes is not trivial for kind=1: the SAD can be different on each plane, it could happen that e.g. SAD on Y plane is small, but SAD on V plane is big.
So, output of MVMask is "colorfull", because U,V planes contain information according to kind's type.
Last: Default U/V mode for most (however not all) mt_MaskTools filters is U=V=1, which means to "trash" chroma. Afterwards, the colorplanes may appear to contain information (sometimes it seems even useful), but infact the the chroma planes hold only random junk after U=V=1.
U=V=2 means keep chroma of the 1st clip argument.
Now look again at
mb1 = fields.MVMask(bv1,kind=1,ml=150,Ysc=255)
mb1b = mt_binarize(mb1,threshold=254,upper=true, U=?,V=?)
1) MVMask delivers meaningful information on U,V planes
2) If you want only greyscale, you have to do that *after* mt_binarize(). Either add a greyscale(), or set U=V=-128 in mt_binarize.
gzarkadas & Didée :thanks:
This script
LoadPlugin("mt_masktools-25.dll")
AVISource("flower.avi")
AssumeTFF()
ConvertToYV12(interlaced=true)
fields=SeparateFields()
bv1 = fields.MVAnalyse(blksize=8, isb = true, truemotion=true, search=2, delta = 2, idx = 1, overlap=4,chroma=false)
mb1=fields.MVMask(bv1,kind=1,ml=50,Ysc=255)
mb1b=mt_binarize(mb1,threshold=254,upper=true,u=-128,v=-128)
StackVertical(mb1,mb1b)
give folowing picture:
http://img395.imageshack.us/img395/2406/maskcr1xw5.th.png (http://img395.imageshack.us/my.php?image=maskcr1xw5.png)
Where at mb1 pink area at mb1b dark. At mb1 pink area correspond fast motion objects. I want construct mask with value 255 for bad motion compensation and 0 for good the same. At mb1b value 255 correspont white color? Or I need use
mb1b=mt_binarize(mb1,threshold=254,upper=false,u=-128,v=-128)
for my purpose.
yup.
mt_binarize question.
http://avisynth.org/mediawiki/MaskTools/Binarize
The Binarize filter allows a basic thresholding of a picture. If upper=true, a pixel whose value is strictly superior to threshold will be set to zero, else to 255. On the contrary, if upper=false, a pixel whose value is strictly superior to threshold will be set to 255, else to zero.
Defaults are threshold = 20 and upper = true.
At http://manao4.free.fr/masktools-v2.0a35.zip masktools/documentation/mt_masktools.html writen
mt_binarize
mt_binarize : clip c, int threshold(128), bool upper(false)
If upper is false, forces all values strictly over threshold to 0, and all others to 255.
Else, forces all values strictly over threshold to 255, else to 0.
upper = true is equivalent to mt_lut("x threshold > 0 255 ?"), but faster.
upper = false is equivalent to mt_lut("x threshold > 255 0 ?"), but faster.
Where can find true?
yup.
gzarkadas
5th June 2008, 22:33
...Where can find true?...
The mt_masktools.html states the correct values (128, false); the wiki page you are refering, documents MaskTools version 1.x, not MaskTools version 2.x ;).
The wiki pages for the new masktools is http://avisynth.org/mediawiki/MaskTools2. When the sub-page for mt_binarize will be written, it will contain the same values for the parameters.
Hi all!
I try writing script:
LoadPlugin("mt_masktools-25.dll")
LoadPlugin("VerticalCleanerSSE2.dll")
LoadPlugin("SSE2Tools.dll")
LoadPlugin("RemoveGrainTSSE2.dll")
DirectShowSource("seldv.avi")
#AVISource("select.avi")
AssumeBFF()
ConvertToYV12(interlaced=true)
fields=SeparateFields()
fieldsf=fields.VerticalCleaner(mode=2)
bv1 = fieldsf.MVAnalyse(blksize=8, isb = true, truemotion=true, search=2, delta = 2, idx = 1, overlap=4, dct=0,chroma=false)
bv2 = fieldsf.MVAnalyse(blksize=8, isb = true, truemotion=true, search=2, delta = 4, idx = 1, overlap=4, dct=0,chroma=false)
fv1 = fieldsf.MVAnalyse(blksize=8, isb = false, truemotion=true, search=2, delta = 2, idx = 1, overlap=4, dct=0,chroma=false)
fv2 = fieldsf.MVAnalyse(blksize=8, isb = false, truemotion=true, search=2, delta = 4, idx = 1, overlap=4, dct=0,chroma=false)
bc1 =fields.MVCompensate(bv1, idx=2, mode=1, thSAD=16000)
bc2 =fields.MVCompensate(bv2, idx=2, mode=1, thSAD=16000)
fc1 =fields.MVCompensate(fv1, idx=2, mode=1, thSAD=16000)
fc2 =fields.MVCompensate(fv2, idx=2, mode=1, thSAD=16000)
mf1=fieldsf.MVMask(fv1,kind=1,ml=150,Ysc=255)
mf2=fieldsf.MVMask(fv2,kind=1,ml=150,Ysc=255)
mb1=fieldsf.MVMask(bv1,kind=1,ml=150,Ysc=255)
mb2=fieldsf.MVMask(bv2,kind=1,ml=150,Ysc=255)
maskcenter=mt_invert(mt_logic(mf1,mb1,"max",u=-128,v=-128))
maskbw=mt_invert(mt_logic(mb1,mb2,"max",u=-128,v=-128))
maskfw=mt_invert(mt_logic(mf1,mf2,"max",u=-128,v=-128))
mcfcenter=clense(bc1, fields,fc1,increment=0)
mcfbw=clense(bc1, fields,bc2,increment=0)
mcffw=clense(fc1, fields,fc2,increment=0)
mcfmasked=mt_merge(fieldsf,mcfbw,maskbw,luma=true)
mcfmasked=mt_merge(mcfmasked,mcffw,maskfw,luma=true)
mcfmasked=mt_merge(mcfmasked,mcfcenter,maskcenter,luma=true)
This script work before and at scene changes. For some frames better work:
mcfmasked=mt_merge(fieldsf,mcfcenter,maskcenter,luma=true)
mcfmasked=mt_merge(mcfmasked,mcfbw,maskbw,luma=true)
mcfmasked=mt_merge(mcfmasked,mcffw,maskfw,luma=true)
How find criteria for choosing priority central or ????ward motion compensation?
yup.
Vesi
11th June 2008, 15:03
mt_masktools-25.dll & mt_masktools-26.dll. Is the 25 meant for avisynth 2.5... and 26 fo avisytn 2.6...?
LaTo
11th June 2008, 16:40
mt_masktools-25.dll & mt_masktools-26.dll. Is the 25 meant for avisynth 2.5... and 26 fo avisytn 2.6...?
mt_masktools-25.dll -> avisynth 2.5.x
mt_masktools-26.dll -> avisynth 2.6.x
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.