View Full Version : Create a block difference mask of two images?
shoopdabloop
21st November 2009, 10:48
I was wondering how one would go about looking at two frames/clips, dividing each into 8x8 (or 4x4) blocks, and comparing each block in one image to the corresponding block in the other and setting the value of the corresponding block in the mask clip to the SAD of the pixels.
So basically, seeing in which corresponding blocks two images match up the most.
Is this possible in MVTools?
Didée
21st November 2009, 21:06
Very easy way to get the normalized SAD over 8x8 blocks:mt_lutxy(clip1,clip2,"x y - abs").DCTFilterD(14)
Alas, the result may show up a small bug in DCTFilter that never was fixed. (Result should show only solid 8x8 blocks everywhere. But in fact, there are many blocks with a 'stripe' in the middle. The bug can be worked around by adding Pointresize(1/8 resolution).PointResize(1/1 resolution). )
(Ab)using MVTools is by all means possible, but rather slow.
Calculate vectors against same frame {interleave(clip1,clip1)}, re-calculate with MRecalculate on {interleave(clip1,clip2)}, get SAD mask via MMask(), then selecteven().
shoopdabloop
21st November 2009, 22:48
would this work also? or is BilinearResize not sampling all 8 pixels?
mt_lutxy(clip1,clip2,"x y - abs",chroma="process").bilinearresize(width/8,height/8).pointresize(width,height)
Gavino
21st November 2009, 23:58
bilinearresize(width/8,height/8) will sample 16x16 pixels at a time.
You could use bilinearresize(width/4,height/4, 2.0. 2.0) , which will give you 8x8 blocks, but the sampling is such that you don't get a simple average, points nearest the centre of each block get more weight, varying linearly (maybe that's what you want, I don't know).
* followed by .pointresize(width/8,height/8).pointresize(width,height)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.