Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 29th October 2004, 17:51   #1  |  Link
tsp
Registered User
 
tsp's Avatar
 
Join Date: Aug 2004
Location: Denmark
Posts: 807
medianblur 0.84 a variable radius spatial/temporal median blur filter

The filter should be fully functional now. Get it here.
You can follow the development in this thread.

From the readme:


medianblur 0.84


medianblur is a spatial median blur filter with a variable radius.
If you want to use it with radius 1 consider using removegrain(mode=4) instead.
medianblurcw is a centerweighted medianblur filter with a variable radius.
medianblurb is binary medianblur filter. It will take advantage of integer SSE if present.
medianblurt is a temporal-spatial median blur filter with optional motion compensation using Manaos MVTools.
If you want to use it with a temporal and spatial radius of 1 consider using DeGrainMedian(limitY=255,limitUV=255,mode=0)

ML3Dex means extended multilevel 3 Dimensional filtering. This filter should cause less artifact compared to medianblurt while removing the same amount of noise. This filter can also use MVTools for motion compensation. The filter is based on the description in: MOTION PICTURE RESTORATION. by Anil
Christopher Kokaram. Ph.D. Thesis. May 1993 (http://www.mee.tcd.ie/~ack/papers/a4ackphd.ps.gz) (Fizick thanks for finding this ;-) )



Usage:

medianblur(clip,int radiusy,int radiusu,int radiusv,bool calcborder)

radiusy,u & v: specify the radius to use. Default is 2. If the supplied radius is between -1 and -255
the plane is set to -radius. If the the radius is 0 the plane is copied unaltered. If the radius is
less than -255 the plane isn't processed at all.

calcborder: if true (default) the borders of the frame is filtered too. If false then the border is copied from the source clip.

for the centerweighted version:



medianblurcw(clip,int radiusy,int radiusu,int radiusv,int weighty,int weightu,weightv, bool calcborder)

weighty,u & v: specify the centerweight = number of times the centerpixel should be replicated. Default 1.



binary mask version:

medianblurcw(clip,int radiusy,int radiusu,int radiusv,int thresholdy,int thresholdu,thresholdv, bool calcborder)

thresholdy,u & v: specify the threshold to use to make the mask. Afterwards the mask is medianblured. Default 127.


temporal medianblur:


medianblurt(clip,int radiusy,int radiusu,int radiusv,int temporalradius, bool mc, bool calcborder,bool markscenechange,int blksize,int pel,int lambda, int thSCD1, int thSCD2,bool spfull,bool bsfull)

radiusy,u & v: same as medianblur with the small difference that radius can be set to 0.
This disable spatial blurring. If you want to copy the plane set it to -1

temporalradius: Number of frames to search before and after current frame. Default 2.

mc: Use Motion Compensation. This is achieved using Manaos MVTools. It's has only been tested with version 0.9.8.1 .
Get it in this thread: http://forum.doom9.org/showthread.ph...0&pagenumber=1 or here http://manao4.free.fr/MVTools-v0.9.8.1.zip
Don't use version 0.9.8.0. This version would cause an error. Default is false.

markscenechange: If set to true there will be a red square in the upper left corner when MVTools detects a scenechange.
If this happens to often the temporal filtering will be decreased. Increase thSCD1 or thSCD2. Default false.

blksize,pel,lambda,thSCD1,thSCD2,searchparam: Parameters to control MVTools. for the meaning of each parameter see MVTools documentation.
Defaults:blksize 4, pel 1, lambda 1000,thSCD1 200,thSCD2 175,searchparam=1

bsfull,spfull: If set to true the blocksize(bsfull) and/or searchparam(spfull) are applied to the frames before the current frame and the frames after.
If set to false then they are only applied to the frames before the current frame. This speeds the motion compensation up but decrease the posible noise reduction.
Defaults are false,false.


extended Multi Level 3Dimensional:

ml3dex(clip,bool mc, int Y, int U, int V,bool markscenechange, int blksize, int pel, int lambda, int thSCD1, int thSCD2,bool spfull,bool bsfull)

good values for cartoons are ml3dex(blksize=4,searchparam=60,lambda=0,thSCD1=1000)

mc: Use Motion Compensation. This is achieved using Manaos MVTools. It's has only been tested with version 0.9.8.1 and 0.9.8.4.
Get it in this thread: http://forum.doom9.org/showthread.ph...0&pagenumber=1 or here http://manao4.free.fr/MVTools-v0.9.8.1.zip
Don't use version 0.9.8.0. This version would cause an error. Default is false.

markscenechange: If set to true there will be a red square in the upper left corner when MVTools detects a scenechange.
If this happens to often the filter can't remove scratches and larger defects as efficient. Increase thSCD1 or thSCD2. Default false.

blksize,pel,lambda,thSCD1,thSCD2,searchparam: Parameters to control MVTools. for the meaning of each parameter see MVTools documentation.
Defaults: blksize 8, pel 1, lambda 1000,thSCD1 200,thSCD2 200,searchparam=1


Y,U,V: Controls which planes the filter is applied to. If set to 3 the plane will be filter, if 2 the plane will be copied from the source,
if 1 the plane will be ignored and from 0 to -255 the plane will be assigned the absolute value. Default Y 3,U=2, V=2


mc: Use Motion Compensation. This is achieved using Manaos MVTools. It's has only been tested with version 0.9.8.1 and 0.9.8.4.
Get it in this thread: http://forum.doom9.org/showthread.ph...0&pagenumber=1 or here http://manao4.free.fr/MVTools-v0.9.8.1.zip
Don't use version 0.9.8.0. This version would cause an error. Default is true.

blksize,pel,lambda,thSCD1,thSCD2: Parameters to control MVTools. for the meaning of each parameter see MVTools documentation.
Defaults: blksize 4, pel 1, lambda 1000,thSCD1 200,thSCD2 175

bsfull,spfull: If set to true the blocksize(bsfull) and/or searchparam(spfull) are applied to the frames before the current frame and the frames after.
If set to false then they are only applied to the frames before the current frame. This speeds the motion compensation up but decrease the posible noise reduction.
Defaults are false,false.



changelog:

Version 0.1 First version. Really slow and buggy. Used a modified bubblesort to find the median causing the filter to be extremely slow with large radii.

Version 0.2 Changed the sort algorithm to radix sort resulting in a great speed improvement especially for large radii. Also fixed a couple of bugs.

Version 0.3 optimized the sort algorithm even more. Also added the ability to process the borders.

version 0.31 bugfix. Should make the same output as tmedianblur except for the borders.

version 0.4 Added medianblurcw a centerweighted median blur

version 0.5 Added medianblurb and medianblurt.

version 0.6 Fixed a couple of bugs and added iteger SSE optimization for medianblur for radius below 4. This results in a 85-400% speed increase

version 0.65 More bugs removed. Added assembler optimization resulting in 30-60% speedincrease for medianblurcw, medianblurt and medianblur(for radius >3)

version 0.7 Added support for motion compensation in medianblurt using manaos MVTools.

version 0.8 Added ML3Dex a multilevel temporal medianblur filter that can use MVTools for motion compensation.

version 0.81 Bugfixes and added an option to show when mvtools detects a scenechange.

version 0.82 fixed a bug that caused a access violating in medianblurt and ml3dex

version 0.83 fixed a bug causing a memory leak with motion compensation. Now calls MVTools with named arguments. This should increase support of different versions of MVTools.

version 0.84 Added the option searchparam bsfull and spfull to ml3dex and medianblurt.

sourcecode released under GPL se copying.txt

Thanks to Manao for creating MVTools.

Last edited by tsp; 6th December 2004 at 18:51.
tsp is offline   Reply With Quote
Old 31st October 2004, 17:19   #2  |  Link
Mug Funky
interlace this!
 
Mug Funky's Avatar
 
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
weeeee! thanks, tsp. temporal median looks like it'll be very useful for removing spots and stuff.
__________________
sucking the life out of your videos since 2004
Mug Funky is offline   Reply With Quote
Old 14th November 2004, 20:06   #3  |  Link
tsp
Registered User
 
tsp's Avatar
 
Join Date: Aug 2004
Location: Denmark
Posts: 807
Updated to version 0.6.
tsp is offline   Reply With Quote
Old 15th November 2004, 16:50   #4  |  Link
Mug Funky
interlace this!
 
Mug Funky's Avatar
 
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
temporal median works well for heavily scratched stuff. now i've just got to nut out how to protect the stream from the massive artefacts i get on motion, while keeping the removed spots removed.

thanks for this plugin
__________________
sucking the life out of your videos since 2004
Mug Funky is offline   Reply With Quote
Old 15th November 2004, 21:43   #5  |  Link
tsp
Registered User
 
tsp's Avatar
 
Join Date: Aug 2004
Location: Denmark
Posts: 807
well the plugin don't have any motion compensation. Maybee MVTool or Depan can be used.
tsp is offline   Reply With Quote
Old 19th November 2004, 15:54   #6  |  Link
krieger2005
Registered User
 
krieger2005's Avatar
 
Join Date: Oct 2003
Location: Germany
Posts: 377
Please correct the Documentation:

Quote:
temporal medianblur:


medianblurcw(clip,int radiusy,int radiusu,int radiusv,int temporalradius, bool calcborder)
should be

Quote:
temporal medianblur:


medianblurt(clip,int radiusy,int radiusu,int radiusv,int temporalradius, bool calcborder)
Thanks for your work
krieger2005 is offline   Reply With Quote
Old 20th November 2004, 17:52   #7  |  Link
tsp
Registered User
 
tsp's Avatar
 
Join Date: Aug 2004
Location: Denmark
Posts: 807
Thanks for finding that little error. Should be fixed now.
tsp is offline   Reply With Quote
Old 21st November 2004, 22:11   #8  |  Link
tsp
Registered User
 
tsp's Avatar
 
Join Date: Aug 2004
Location: Denmark
Posts: 807
version 0.65 released. Contains some assembler optimization of the critical functions. This causes a 20-60 % speed increase. I'm not really impressed by the compiler. Thought it would be better to optimize the code.
tsp is offline   Reply With Quote
Old 21st November 2004, 22:25   #9  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
Join Date: Nov 2003
Location: Russia
Posts: 2,183
tsp,
Have you any plans to include multi-level median filter?
It must produce less blur.
__________________
My Avisynth plugins are now at http://avisynth.org.ru and mirror at http://avisynth.nl/users/fizick
I usually do not provide a technical support in private messages.
Fizick is offline   Reply With Quote
Old 22nd November 2004, 18:37   #10  |  Link
tsp
Registered User
 
tsp's Avatar
 
Join Date: Aug 2004
Location: Denmark
Posts: 807
Quote:
Originally posted by Fizick
tsp,
Have you any plans to include multi-level median filter?
It must produce less blur.
What do you men with multilevel? the center weighted version produces less blur if you use a high enough value for the weight (a little less than (radius*2+1)^2 would be fine).
tsp is offline   Reply With Quote
Old 23rd November 2004, 00:23   #11  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
Join Date: Nov 2003
Location: Russia
Posts: 2,183
http://www.mee.tcd.ie/~ack/papers/a4ackphd.ps.gz
__________________
My Avisynth plugins are now at http://avisynth.org.ru and mirror at http://avisynth.nl/users/fizick
I usually do not provide a technical support in private messages.
Fizick is offline   Reply With Quote
Old 28th November 2004, 23:30   #12  |  Link
tsp
Registered User
 
tsp's Avatar
 
Join Date: Aug 2004
Location: Denmark
Posts: 807
updated to version 0.70. medianblurt can now use Manaos MVTools for motion compensation. This should please Mug Funky . Next project should be a multilevel median blur.

please note that this filter has only been tested with MVTools 0.9.8.1. 0.9.8.0 craches avisynth.
tsp is offline   Reply With Quote
Old 3rd December 2004, 20:40   #13  |  Link
tsp
Registered User
 
tsp's Avatar
 
Join Date: Aug 2004
Location: Denmark
Posts: 807
version 0.80 ready. Now includes a multi-level median filter called ML3Dex, which also supports MVTools for motion compensation. Give it a try.
tsp is offline   Reply With Quote
Old 4th December 2004, 16:37   #14  |  Link
tsp
Registered User
 
tsp's Avatar
 
Join Date: Aug 2004
Location: Denmark
Posts: 807
Forgot to enable assembler optimization. Fixed that and added an option to show when MVTools detects a scene change. Really useful with ML3Dex because this filter don't functions well if all frames are detected as scene changes. So get version 0.81.
tsp is offline   Reply With Quote
Old 4th December 2004, 17:30   #15  |  Link
Mug Funky
interlace this!
 
Mug Funky's Avatar
 
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
oh, i haven't been following this thread, but i should have been

will try that ml3d whatsit and report back. i've got a great clip to test it on - the "duck and cover" video from www.archive.org (it was posted in general discussion). so far i'm using MVtools, clense (like medianblurt(0,0,0,1) but faster), and degrainmedian/removedirt plus fft3dfilter by fizick. slow slow slow the results can only be described as "okay" at the moment. this is a very tough clip.

[edit]

wow! i mean wow!

even at defaults ml3dex gives a good result. nice work. now to try it with motion compensation...

[edit 2]

motion compensation is nice too this is the best christmas ever

it gets pretty blocky in parts though. are there any parameters to ml3dex apart from the MC related ones?

[edit 3]

i get an access violation when i do it this way:
Code:
odd=separatefields().selectodd().ml3dex()
even=separatefields().selecteven().ml3dex()
interleave(odd,even).weave()
i'm going to bed now
__________________
sucking the life out of your videos since 2004

Last edited by Mug Funky; 4th December 2004 at 18:04.
Mug Funky is offline   Reply With Quote
Old 4th December 2004, 20:37   #16  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
Join Date: Nov 2003
Location: Russia
Posts: 2,183
tsp,
thanks for filter and ml3dex!

And you may thanks me for info also
__________________
My Avisynth plugins are now at http://avisynth.org.ru and mirror at http://avisynth.nl/users/fizick
I usually do not provide a technical support in private messages.
Fizick is offline   Reply With Quote
Old 4th December 2004, 22:30   #17  |  Link
tsp
Registered User
 
tsp's Avatar
 
Join Date: Aug 2004
Location: Denmark
Posts: 807
Quote:
Originally posted by Fizick
tsp,
thanks for filter and ml3dex!

And you may thanks me for info also
Sure thing if you implement the 2DAR model (chapter 5) for jitter correction

Mug Funky I didn't have any problems with blocky parts yet. Is it a heavy compressed source? Maybe Deblock from MVTools can help. you can try this:
Code:
c=last 
vfw = c.mvanalyse(pel=1, isb=false, blksize=8)
vbw = c.mvanalyse(pel=1, isb=true, blksize=8)
interleave(c.mvcompensate(vfw, thSCD1=1000),c,c.mvcompensate(vbw, thSCD1=1000)).Deblock(40,16,16).ml3dex(false).selectevery(3,1)
If it helps I will implement it in the next version.

Fixed the bug that caused a access violation. It was caused by different pitch in some of the source frames. Get version 0.82 above.

I also discovered a memory leak with MC=true. I think it's caused by MVTools combined with env->Invoke. It doesn't happend when using the above script so until it's fixed use the above script instead if you want motion compensation for more than 1000 frames.

Last edited by tsp; 4th December 2004 at 22:43.
tsp is offline   Reply With Quote
Old 5th December 2004, 03:43   #18  |  Link
Mug Funky
interlace this!
 
Mug Funky's Avatar
 
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
thanks. no more access violation

it seems MC is true by default in this new release...

also, if you want to see blocking, try fast moving anime with ml3dex(mc=true) and you'll probably see it. unless there's something wacky about it at my end (i'm not eliminating this possibility...). it'll show up on natural video as well, but anime is a sure way to screw up motion-compensation, and thus a good way to show blocking.
__________________
sucking the life out of your videos since 2004

Last edited by Mug Funky; 5th December 2004 at 03:49.
Mug Funky is offline   Reply With Quote
Old 5th December 2004, 04:38   #19  |  Link
morsa
the dumbest
 
Join Date: Oct 2002
Location: Malvinas
Posts: 494
Is multilevel median the one which uses intead of a matrix first an X mask and then a cross one?
morsa is offline   Reply With Quote
Old 5th December 2004, 13:45   #20  |  Link
tsp
Registered User
 
tsp's Avatar
 
Join Date: Aug 2004
Location: Denmark
Posts: 807
Quote:
Is multilevel median the one which uses intead of a matrix first an X mask and then a cross one?
yes in fact it uses 5 mask. Finds the median of each of them and then returns the median of the medians. The 5 masks look like this:
Code:
prev frame       .    .     .    x      +
current frame    +    x     .    .      .
next frame       .    .     .    x      +
.=center pixel  x=diagonal mask  +=crossmask
tsp is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 13:39.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.