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 14th February 2004, 02:44   #21  |  Link
FuPP
TotalEclipseOfTheBrain
 
FuPP's Avatar
 
Join Date: Sep 2002
Posts: 347
Here is a new avsi. This one enables you to show Edge detection mask (with debug = 1), show motion mask (with debug = 2), change motion detection threshold, (parameter M_Thr) and change scene change detection threshold for motion detection (parameter M_SCD).

Of course you still can change edge sharpning strength using parameter Sharpness, change unfilter strength (for sharpening only, for now...) with sh1 and sh2 parameters.


1/ AVSI

the following lines should be copied and pasted in notepad, and then saved as "hybridfupp.avsi" in your avisynth plugins directory (by default : C:\Program Files\AviSynth 2.5\plugins) :

Code:
Function HybridFupp(clip input, int width, int height, int "sharpness", int "sh1", int "sh2", int "M_Thr", int "M_SCD", int "debug") 

{
global input      = input
global width      = width
global height     = height
global sharpness  = sharpness
global sh1        = sh1
global sh2        = sh1
global M_Thr      = M_Thr
global M_SCD      = M_SCD

Sharpness         = Default(sharpness, 255)
M_Thr             = Default(M_Thr, 30)
M_SCD             = Default(M_SCD, 15)
sh1               = Default(sh1, 40) 
sh2               = Default(sh2, 12)

Blank = BlankClip(1,width,height,color=$FFFFFF,pixel_type="YV12")

Frame = (debug == 1) ? MaskedMerge(input.Bilinearresize(width,height), Blank, RM(input,width, height, sharpness)) : \
  (debug == 2) ? MaskedMerge(input.BilinearResize(width,height), Blank, MM(input,width, height, M_Thr, M_SCD)) : \
  FuPP(input,width, height,sharpness,sh1,sh2,M_Thr,M_SCD)


return Frame
}



function FuPP(clip input, int width, int height, int "sharpness", int "sh1", int "sh2", int "M_Thr", int "M_SCD")
{

RM = RM(input,width, height, sharpness)
MM = MM(input,width, height, M_Thr, M_SCD)

Soft = input.BilinearResize(width, height) 

MEdgesharp  = input.LanczosResize(width, height).unfilter(sh1,sh2)
MMotionblur = soft.unfilter(-10,-10)

Addedgedsharp = MaskedMerge(soft.fluxsmooth(3,5), MEdgesharp, RM) 
AddMotionblur = MaskedMerge(Addedgedsharp , MMotionblur, MM )

return AddMotionblur
}



function RM(clip i,Int w,Int h, Int s)
{
ResizeMask = i.edgemask(3,8,255,255,"sobel",Y=3, V=1, U=1).inflate().\
Levels(0, 1.0, 24, 0, 255).Levels(0,1.0,255,0,s).BilinearResize(w, h)

return ResizeMask
}



function MM(clip i,Int w,Int h, Int m_s, Int m_scd)
{

MoMask = motionmask(i, thY1= m_s, thY2= m_s, thSD= M_scd, y=3, u=1, v=1).fity2uv().\
inflate().Levels(0, 1.0, 24, 0, 255).BilinearResize(w, h)

return MoMask
}


2/ examples

a/ hybridFupp(448,320,220,36,10,20,16,debug=2)

means :

width = 448 (resizing)
height = 320 (resizing)
Edge sharpening strength = 220
unfilter(36,10)
motion threshold = 30
scene change detection = 16
Please show me motion mask, FuPP (debug = 2)


b/ hybridFupp(448,320,255,40,12,30,15,debug=0)

means : hybridFuPP(448,320) cause you are using default parameters.


3/ To do

- Didée is right. there's room for motion detection improvement, as the algo seems to fail time to time.
- Make parameters for edge detection threshold, for fluxsmooth and unfilter (for the bluring part) : easy to do, so probably for very soon.
- Go to bed.


Regards,

FuPP

Last edited by FuPP; 14th February 2004 at 10:46.
FuPP is offline   Reply With Quote
Old 14th February 2004, 09:21   #22  |  Link
Inc
Squeeze it!
 
Inc's Avatar
 
Join Date: Oct 2003
Location: Germany
Posts: 472
I can't get it work !

Avisynth Vers. 2.54
Masktools: masktools_25_dll_20040110.zip

My script

Code:
LoadPlugIn("C:\Programme\AviSynth 2.5\pluginsExtra\MaskTools.dll")
AVISource("H:\vdubcap.avi")
Hybridfupp(480,576,255,40,12,30,15,debug=0)
First in my case I have to load "masktools.dll" from another folder instead of beeing autoloaded by avs in the avs 2.5 plugins folder.

Then if I run that script Vdubmod outputs the following error:
"Motionmask does not have a anmed argument "thY1"
(_tvpv, line 64)
(_tvpv, line 35)
(_tvpv, line 23)

Any idea?
Inc is offline   Reply With Quote
Old 14th February 2004, 10:11   #23  |  Link
FuPP
TotalEclipseOfTheBrain
 
FuPP's Avatar
 
Join Date: Sep 2002
Posts: 347
You should use masktools 1.4.9

You'll find the new version here ( As always, right click, copy adress and paste it if it doesn't work the first time )

FuPP
FuPP is offline   Reply With Quote
Old 14th February 2004, 10:14   #24  |  Link
bond
Registered User
 
Join Date: Nov 2001
Posts: 9,770
fupp,
maybe you want to have a look at the question i posted in my last post!?
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau)
I know, that I know nothing (Socrates)

MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide)
Ogg Theora | Ogg Vorbis
use WM9 today and get Micro$oft controlling the A/V market tomorrow for free
bond is offline   Reply With Quote
Old 14th February 2004, 10:54   #25  |  Link
FuPP
TotalEclipseOfTheBrain
 
FuPP's Avatar
 
Join Date: Sep 2002
Posts: 347
@Bond : Oops ! did not see your previous post, sorry.

Inflate is used in order to get larger edges in the mask. Without it, sharp resizing of edges wouldn't be efficient.

Greyscale was only for testing purposes and I had forgotten to remove it before posting the first time. (NB : in the new version, you can see masks using debug parameter).

Levels : I honestly can't remember why I have put that (I've made so many tests) ; I think they can be removed except one, due to Manao modifications (used for parameter sharpness).


I can't see the ghosting effect you describe. Could you please have a look with debug=2 ?


@manao : Pictures ? Why not... I will try to post today.


FuPP

Last edited by FuPP; 14th February 2004 at 11:07.
FuPP is offline   Reply With Quote
Old 14th February 2004, 11:10   #26  |  Link
bond
Registered User
 
Join Date: Nov 2001
Posts: 9,770
thanks a lot

i forgot one thing: why did you use fity2uv()?


ad ghosting:
to make it visible what i meant with the ghosting effect i described, have a look at these pictures imho showing it very well
look at the left hand of agent smith, he is moving it from the left to the right and imho its very good visible how the place where the hand was 1 frame before is still blurred in the current frame too

for ghosting1 i used .ConvertToRGB32().RGBAdjust(5,1,1,1) to color the areas and Layer(), as you used it in your first script, as maskedmerge needs yv12 input (red is the motionarea, yellow are the edges, blue is nomo-noedg (labeled as soft by fupp))
edit: its also there with .ConvertToRGB32().RGBAdjust(5,1,1,1).ConvertToYV12() and maskedmerge

the same result with ghosting2, using fupps latest script and debug=2
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau)
I know, that I know nothing (Socrates)

MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide)
Ogg Theora | Ogg Vorbis
use WM9 today and get Micro$oft controlling the A/V market tomorrow for free

Last edited by bond; 14th February 2004 at 18:02.
bond is offline   Reply With Quote
Old 14th February 2004, 11:16   #27  |  Link
Inc
Squeeze it!
 
Inc's Avatar
 
Join Date: Oct 2003
Location: Germany
Posts: 472
Thanks for the link - it works! Right testing now.
Inc is offline   Reply With Quote
Old 14th February 2004, 12:15   #28  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,389
Quote:
Originally posted by bond
funny when i color the motion parts red (with .ConvertToRGB32().RGBAdjust(5,1,1,1) ) i see an effect i could describe as ghosting, meaning if a person moves also parts get blurred where the person was a frame before altough it isnt there anymore...
why that?
This I noticed also when I was preparing a similar script (my attention was initially drawn by the sword fights of LOTR, where the effect was really obvious.)

But it is not surprising at all. The used calculation of motion is very basic: it works by either something like frame differencing, or by evaluating a comb mask between current/next frame - I didn't look into the source, but the result is just the same:
imagine a fast moving object, that is located in the left part of the current frame, and in the right part of the next frame. Building the difference between these two frames will return a difference in *both* locations of the object, but on the current frame.
This is absolutely normal, and there is nothing to do about the matter without implementing a real motion tracking algorithm. Which probably would be painfully slow.
One possibility could be to use the scene change detection not on the complete frame, but instead do a windowed search. Then, each "window" that has a difference > threshold from the temporal neighbored window could be excluded. But this would raise other problems, related to the block-based decisions.

- Didée
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 14th February 2004, 12:50   #29  |  Link
bond
Registered User
 
Join Date: Nov 2001
Posts: 9,770
Quote:
Originally posted by Didée
Building the difference between these two frames will return a difference in *both* locations of the object
ah yes of course, stupid me


btw your comments about the scene threshold are very valid (too), in my test clip (matrix1) i think the best would be 22 or 23, above that too often the scene changes werent detected
25 is imho the absolute maximum, but of course its a question of personal preference:
at first sight i would say i prefer better scene change detection than better high-motion blurring (cause this avoids that whole frames after scene changes get blurred, cause the scene change wasnt detected) and because the codec can still blurr the high-motion itself but it cant sharpen the falsely blurred not detected scene changes

i am currently testing if this "scene change blurring" can be seen anyway (if not i will go up with this value), maybe someone else already has extensively tested this and can report findings?
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau)
I know, that I know nothing (Socrates)

MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide)
Ogg Theora | Ogg Vorbis
use WM9 today and get Micro$oft controlling the A/V market tomorrow for free

Last edited by bond; 14th February 2004 at 13:04.
bond is offline   Reply With Quote
Old 14th February 2004, 15:29   #30  |  Link
FuPP
TotalEclipseOfTheBrain
 
FuPP's Avatar
 
Join Date: Sep 2002
Posts: 347
SCD : I'm doing some tests because I think that 25 is too strong too. I think that good values are between 19 and 25.

btw : the question you raise aboute SCD (is it visible ?) is the same for ghosting effect. I would be quite surprised if you can see an obvious quality lost.

I'm still working on tweaking, and default values will probably be changed in next version.

Thanks everybody for the time you give for testing.

Regards,

FuPP
FuPP is offline   Reply With Quote
Old 14th February 2004, 16:04   #31  |  Link
mf
·
 
mf's Avatar
 
Join Date: Jan 2002
Posts: 1,729
Why is SCD necessary for a mask filter? Since when did that become logical? If MotionMask is only giving you a 1-bit mask, try YV12Subtract to create a motion mask, which should give you variations. I might dig into it .
mf is offline   Reply With Quote
Old 14th February 2004, 17:03   #32  |  Link
pjotor
Registered User
 
Join Date: Mar 2003
Location: Finland
Posts: 15
anybody know how to fix this?

Avisynth open failure:
Evaluate: operands of '==' and '!=' must be comparable
(hybrv, line 23)


Code:
LoadPlugin("D:\DVD Tools\GordianKnot\mpeg2dec3.dll")
LoadPlugin("D:\DVD Tools\GordianKnot\masktools.dll") 
LoadPlugin("D:\DVD Tools\GordianKnot\unfilter.dll") 
LoadPlugin("D:\DVD Tools\GordianKnot\undot.dll")
LoadPlugin("D:\DVD Tools\GordianKnot\fluxsmooth.dll") 
mpeg2source("D:\Mission Impossible 2\mi2.d2v")
crop(12,84,698,404,align=true)
Undot()
hybridFupp(640,256)
For some reason it works fine when using debug=1.
Debug=0 and debug=2 returns:
Avisynth open failure:
Evaluate: unrecognised exception!
(hybrv, line 64)
(hybrv, line 23)

pjotor is offline   Reply With Quote
Old 14th February 2004, 17:06   #33  |  Link
Inc
Squeeze it!
 
Inc's Avatar
 
Join Date: Oct 2003
Location: Germany
Posts: 472
Yepp, that happened to me too, it seems that you must define "debug" in the command.
Inc is offline   Reply With Quote
Old 14th February 2004, 17:24   #34  |  Link
FuPP
TotalEclipseOfTheBrain
 
FuPP's Avatar
 
Join Date: Sep 2002
Posts: 347
Oops ! Forgot that in default definitions. Will fix that in next release.

For now, I'm doing compression tests...

FuPP
FuPP is offline   Reply With Quote
Old 14th February 2004, 17:39   #35  |  Link
bond
Registered User
 
Join Date: Nov 2001
Posts: 9,770
Quote:
Originally posted by FuPP
the question you raise aboute SCD (is it visible ?) is the same for ghosting effect. I would be quite surprised if you can see an obvious quality lost.
exactly and nope, its not visible in high-motion scenes (even with unfilter(-150,-150))
in low motion it is for a short time if very strong blurring values are used (-150), with -30 i couldnt really spot the difference anymore (tough its of course visible by a frame to frame compare)

Quote:
I think that good values are between 19 and 25.
hm from my test described above imho the most important thing to look at is if the scene changes are detected in low motion (i want to avoid having blurry low motion frames, even if i dont see them)

i will stay with 23 (dark scenes/movies need a lower value)
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau)
I know, that I know nothing (Socrates)

MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide)
Ogg Theora | Ogg Vorbis
use WM9 today and get Micro$oft controlling the A/V market tomorrow for free

Last edited by bond; 14th February 2004 at 17:56.
bond is offline   Reply With Quote
Old 14th February 2004, 18:50   #36  |  Link
bond
Registered User
 
Join Date: Nov 2001
Posts: 9,770
fupp,
why do you take as value for manipulating the edges your sharpness value and not the thresholds of the edgemask()?
is there any special reason why you choose "sobel" and 3,8 for edgemask?

also i dont really understand why you added FitY2UV only to the motionmask but not to edgemask?
__________________
Between the weak and the strong one it is the freedom which oppresses and the law that liberates (Jean Jacques Rousseau)
I know, that I know nothing (Socrates)

MPEG-4 ASP FAQ | AVC/H.264 FAQ | AAC FAQ | MP4 FAQ | MP4Menu stores DVD Menus in MP4 (guide)
Ogg Theora | Ogg Vorbis
use WM9 today and get Micro$oft controlling the A/V market tomorrow for free

Last edited by bond; 14th February 2004 at 19:01.
bond is offline   Reply With Quote
Old 14th February 2004, 20:59   #37  |  Link
Chainmax
Huh?
 
Chainmax's Avatar
 
Join Date: Sep 2003
Location: Uruguay
Posts: 3,103
Sorry to be such a n00b, but what exactly does this filter do (in layman's terms,please)? What other filters (if any) is it comparable to and how does it stack up against them?
Chainmax is offline   Reply With Quote
Old 14th February 2004, 21:02   #38  |  Link
FuPP
TotalEclipseOfTheBrain
 
FuPP's Avatar
 
Join Date: Sep 2002
Posts: 347
Hi bond,

Fity2uv has already been removed for next version (not used anymore).

Sobel seems more sensitive. Of course, you can try other ones and let me know.

Sharpness parameter comes from original Hybridresize. I can remove it if people feel it not necessary.

3,8 came from my previous tests. I am probably going to change default 8 -> 15, and create a parameter for it.


Cheers,

Fupp
FuPP is offline   Reply With Quote
Old 14th February 2004, 21:05   #39  |  Link
FuPP
TotalEclipseOfTheBrain
 
FuPP's Avatar
 
Join Date: Sep 2002
Posts: 347
Chainmax,

I don't know, but it looks so good !

Last edited by FuPP; 14th February 2004 at 21:11.
FuPP is offline   Reply With Quote
Old 14th February 2004, 21:10   #40  |  Link
FuPP
TotalEclipseOfTheBrain
 
FuPP's Avatar
 
Join Date: Sep 2002
Posts: 347
ok,

I suppose you have read thread title and first posts...

this filter attempts to use best resizing method, and apply adapted filters by detecting edges and motion parts of each frame.

Moreover, it has been especially designed to deliver a sharp picture, though you can tweak parameters and reduce sharpness.

You should therefore get a sharp and denoised picture, with maximum compressibility.

Hope I've been clear.

FuPP

PS : it a kind of mix with Msharpen and NoMoSmooth

Last edited by FuPP; 14th February 2004 at 21:42.
FuPP 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 16:22.


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