Log in

View Full Version : HybridFuPP : new 0.84b


Pages : [1] 2 3 4 5

FuPP
12th February 2004, 22:43
Here is a script (directly inspired from mf hybridresize) doing resizing + edge, motion and dark areas aware filtering :

- edges are sharply resized (oversharpening is though optional)
- moving areas of each frame are resized with a soft algorithm and spatialy filtered
- dark areas are softly resized and strongly filtered
- other areas are resized with the algorithm of your choice and slightly filtered with a temporal filter.

This function is designed for resizing + filtering, and delivers a sharp image while enabling better compressibility than using bilinear resizing !

You must use avisynth 2.55 load mpeg2dec3, unfilter, undot, fluxsmooth, msharpen (new, since 0.6b) and masktools (v 1.4.14) in your main script (or have them in your avisynth plugin directory)

download avsi 0.84b (2004/03/14) + readme (http://fupp.chez.tiscali.fr/HybridFuPP/HybridFuPP_084_b.zip) (click right on link and save target)

changelog :

0.84b:

- It is now possible to create personal processing chains
- advanced debug mode (displayed with colors, modes can be now combined)
- added a strength parameter for dark areas processing
- more speed
- no more limits concerning final size for chroma and dark (called ‘special’ in 0.7x versions) modes
- deringing (optional) is now done after resizing. Mod 16 size limit concerns now only final size.
- be careful : some parameters have been renamed (ex : special -> dark).
- parameters order has changed ! so be careful if you used unnamed parameters in previous releases : ex hybridFupp(448,320,12,7,10,30,9,32,17,1,5,true,true,true,30,0)

0.80a to 0.83a : not released

0.71b :
- added a threshold parameter for special mode (ie dark areas processing)

0.7b :

- special processing of dark areas (experimental), ie soft resizing + strong filtering (optional). Compressibility : up to 12% more
- It is now possible to choose resizing algorithm for edges
- motion spatial filtering has been re-introduced (because of users request)
- a little bit less speed if dark areas processing is used (activated by default), a little bit more than 0.6b if it is not used


0.6b :

- resizing algorithm and settings can be now selected for picture parts displaying no motion nor edges
- edge detection algorithm changed (uses Msharpen now)
- default values have been changed
- presets have been changed
- it is now possible to override parameters included in a preset
- spatial filtering has been removed when processing motion (offered a very weak compressibility gain)
- general picture quality improvements
- speed improvement

- 0.5b : added presets (low, medium, high, high2)
changed defaults for better quality
changed spatio-temporal filter position in the chain
- 0.4b : add parameters for both spatio-temporal and spatial filtering
changed default value for Edge detection threshold from 15 to 10
chroma smoothing is now done after resizing. Dering is still done before. Will see later...
- 0.3b : errors with non mod16 sources are better managed
- 0.2b : first downloadable version- All feedback will be greatly appreciated -

original script (it has been kept for people who want to understand further discussions, but latest script is included in the downloadable file):



LoadPlugin("C:\video\avsfilters\yv12\mpeg2dec3.dll")
LoadPlugin("C:\video\avsfilters\yv12\masktools.dll")
LoadPlugin("C:\video\avsfilters\yv12\undot.dll")
LoadPlugin("C:\video\avsfilters\yv12\unfilter.dll")
LoadPlugin("C:\video\avsfilters\yv12\fluxsmooth.dll")

mpeg2source("F:\Films\test.d2v",idct=7,cpu2="ooxxox",moderate_h=10,moderate_v=20).crop(24,80,672,416,align=true)
blindpp(quant=2,cpu2="ooooxo",moderate_h=30,moderate_v=50)
HybridFupp(448,320,255,40,12)
colorYUV(off_y=5,gain_y=25,cont_v=-60)
undot()
addBorders(16,128,16,128)


function HybridFupp(clip input, int width, int height, int "sharpness", int "sh1", int "sh2")

{
resizemask = input.edgemask(3,8,255,255,"sobel",Y=3, V=1, U=1).inflate().Levels(0, 1.0, 24, 0, 255).\
BilinearResize(width, height).GreyScale().ConvertToRGB32()

MoMask = motionmask(input,thY1=30,thY2=30,thSD=15,y=3,u=1,v=1).fity2uv().inflate().Levels(0, 1.0, 24, 0, 255).\
BilinearResize(width,height).greyscale().converttorgb32()

soft = input.BilinearResize(width, height)

MEdgesharp = Mask(input.LanczosResize(width, height).unfilter(sh1,sh2).ConvertToRGB32(), resizemask)
MMotionblur = Mask(soft.unfilter(-10,-10).ConvertToRGB32(), MoMask)
Addedgedsharp = Layer(soft.fluxsmooth(3,5).ConvertToRGB32(), MEdgesharp, "add", sharpness)
AddMotionblur = Layer(Addedgedsharp , MMotionblur, "add", 255).converttoyv12()

return AddMotionblur

}



I'm quite happy with results (thanks mf, Kurosu and Manao !)

FuPP

FuPP
13th February 2004, 01:00
I made an avsi version, probably easier to use. Sharpness, sh1 and sh2 are now optional (defaults are 255,40,12)

Remember : avsi files are automatically loaded, so there's no need to load the function in your final script.

1/ avsi file :

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) :

---------------------------------------------------------------------
function HybridFupp(clip input, int width, int height, int "sharpness", int "sh1", int "sh2")

{
sharpness = Default(sharpness, 255)
sh1 = Default(sh1, 40)
sh2 = Default(sh2, 12)

resizemask = input.edgemask(3,8,255,255,"sobel",Y=3, V=1, U=1).inflate().Levels(0, 1.0, 24, 0, 255).\
BilinearResize(width, height).GreyScale().ConvertToRGB32()

MoMask = motionmask(input,thY1=30,thY2=30,thSD=15,y=3,u=1,v=1).fity2uv().inflate().Levels(0, 1.0, 24, 0, 255).BilinearResize(width,height).greyscale().converttorgb32()

soft = input.BilinearResize(width, height)

MEdgesharp = Mask(input.LanczosResize(width, height).unfilter(sh1,sh2).ConvertToRGB32(), resizemask)
MMotionblur = Mask(soft.unfilter(-10,-10).ConvertToRGB32(), MoMask)
Addedgedsharp = Layer(soft.fluxsmooth(3,5).ConvertToRGB32(), MEdgesharp, "add", sharpness)
AddMotionblur = Layer(Addedgedsharp , MMotionblur, "add", 255).converttoyv12()

return AddMotionblur
}
--------------------------------------------------------------------



2/ script examples

ex 1 : crop, 448x320 resizing and addborders are used for svcd specification

LoadPlugin("C:\video\avsfilters\yv12\mpeg2dec3.dll")
LoadPlugin("C:\video\avsfilters\yv12\masktools.dll")
LoadPlugin("C:\video\avsfilters\yv12\unfilter.dll")
LoadPlugin("C:\video\avsfilters\yv12\fluxsmooth.dll")

mpeg2source("F:\Films\test.d2v",idct=7)
crop(24,80,672,416,align=true)
hybridFupp(448,320)
addBorders(16,128,16,128)


ex 2 : similar to previsous post, more optimized for compressibility

LoadPlugin("C:\video\avsfilters\yv12\mpeg2dec3.dll")
LoadPlugin("C:\video\avsfilters\yv12\undot.dll")
LoadPlugin("C:\video\avsfilters\yv12\masktools.dll")
LoadPlugin("C:\video\avsfilters\yv12\unfilter.dll")
LoadPlugin("C:\video\avsfilters\yv12\fluxsmooth.dll")

mpeg2source("F:\Films\test.d2v",idct=7,cpu2="ooxxox",moderate_h=10,moderate_v=20)
crop(24,80,672,416,align=true)
blindpp(quant=2,cpu2="ooooxo",moderate_h=30,moderate_v=50)
hybridFupp(448,320)
undot()
addBorders(16,128,16,128)


Just a last word : I have only used ideas (and code) coming mostly from other people, so I thank them once more !

jkwarras
13th February 2004, 08:45
Wow, thanks a lot for this script, I'll test it as sson as posible :)

If I've undertand correctly (please correct me if I'm wrong), it apply different levels of resizing/bluring/denoising depending on the motion of a frame. So, if for ex. we have an lateral inside car scene, with the driver in front and behind him there's the windows, with all the streets and cars, etc.. passing very quickly. It's that filter keeping the details of the non-moving area (the driver) while bluring the behind scene (moving area: 'paysage' in window)? I mean, applying different levels of denoising/filtering in different parts of the same frame?

If it's this it's incredible!!

One question:

How do you think this script will behave along with the QMF script? This last one is based in motion and apply different levels of denosing/filtering to a *whole* frame.

Regards.

FuPP
13th February 2004, 09:09
1/ Yep ! + edge shapening + non-edge softening (by bilinear resizing)

2/ This is the difference : QMF blurs the whole frame when there's motion. "Mine" blurs only moving parts of picture (so result should be, theoretically speaking, "better").

Didée
13th February 2004, 09:33
AAAAAAAArgh !!

Such a thing is what I wanted to script in the next two weeks or so, I already started with the baselines at end of January.

:(

Okay, over the weekend I'll look closer at it, to find out if we had all the same ideas ...

However, it's very nice to see that people other than mf (and, very seldom, me) are converting good ideas into scripts. Thank you!

[Announcement] And BTW, I'm not completely out of the game: this weekend I'm going to post a little script ... eye candy, time dandy.


FuPP: technical question!

For the same purpose than you, I was playing with "MotionMask" also. But I had non-trivial problems with it:
When using scenechange thresholds low enough to catch the motion just like I wanted it to, THEN very often MotionMask returned black masks in high-motion parts, which is a very bad thing obviously (blurring drops out where you need it the most). IIRC I had to up the SC threshold to something >20~30, or even more (not sure atm). Now I see you use a SC thresh of only (15) ... don't you have problems with high-motion falsly detected as scenechange?

- Didée

FuPP
13th February 2004, 10:03
Yes, calibrating parameters is very touchy. The ones I use gave me good results for the sources I have tested. Maybe you could have a look with these and tell me what happens with samples you've used.

"Such a thing is what I wanted to script in the next two weeks or so, I already started with the baselines at end of January."

Sorry for that... :p

@Kurosu, Manao or Shodan :

I have a technical question too : Is it possible to have Mask function working with YV12 ?

btw, I have had problems using yv12Layer even if source (param1) and mask (param2) are previously converted to yv12. Is it normal ?

jkwarras
13th February 2004, 10:23
Originally posted by FuPP
This is the difference : QMF blurs the whole frame when there's motion. "Mine" blurs only moving parts of picture (so result should be, theoretically speaking, "better").

Cool! Thanks a lot for it, i'll try it :D It seems excellent for my DVD backups!

Well, I'm just guessing here and maybe this isn't of your interest but I think this script will also be really useful for DV filtering with no compressibility purposes. I mean, when you want to filter noise in DV and want to outut it to DV (not to MPEG-4). AS DV Data rate is constant you don't have to care about filesize, just filter efficiently.

As shooting DV is sometimes very difficult and you can get a lot of noise (for ex. on low lighting shooting) on certains scenes and less noisy (but still noisy) on other scenes. The fact is that if you apply denoising to the whole video (like C3D or fluxsmooth) you'll get suboptimal denoising, you can get too much denoising on parts than doesn't need it and get not enough denoising in parts that really need it (and you don't apply enough because you'll also apply too much into the less noisy parts). SO at the end you just have to do it at hand, which is kind of difficult. So, I'm wondering if such a script will be useful for this purposes, turning it into noise based. But maybe noise can be considered as motion. I'm not a programmer, just a final user and independent filmmaker and I really see an use of that, so please, forget about this if you feel is stupid :)

Regards

Mug Funky
13th February 2004, 10:27
hey, cool. i haven't touched video for a week or so, but i'll give this a try when i do.

if you're having trouble with mask and layer, why not use Overlay? fully YV12 masking and stuff... you need the jan 15th binary to get the full benefit (Photoshop style "ink types" like subtract, difference, etc)

FuPP
13th February 2004, 10:32
@jkwarras : you should probably use something like Peachsmoother for that purpose (excellent adaptive filtering by Linsey Dubb).

But I think DV sources are interlaced and I don't know if Peach handle this properly. Btw, you should find some posts in this forum about how filtering interlaced sources using filters that do no handle them natively.

Regards,

FuPP

FuPP
13th February 2004, 10:34
Originally posted by Mug Funky
hey, cool. i haven't touched video for a week or so, but i'll give this a try when i do.

if you're having trouble with mask and layer, why not use Overlay? fully YV12 masking and stuff... you need the jan 15th binary to get the full benefit (Photoshop style "ink types" like subtract, difference, etc)

yes, but what about masks ? (I guess overlay <=> layer ?)

Manao
13th February 2004, 10:50
@FuPP : no need of Mask if your are in YV12 : the Y channel already contains that information.

In fact, mask = Mask(overlay_clip,mask_clip)
Layer(base_clip, mask, "add", 255)Is equivalent toMaskedMerge(base_clip,overlay_clip,mask_clip,Y=3, U=3, V=3)Hence, your code can be changed into function HybridFupp(clip input, int width, int height, int "sharpness", int "sh1", int "sh2")

{
sharpness = Default(sharpness, 255)
sh1 = Default(sh1, 40)
sh2 = Default(sh2, 12)

resizemask = input.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,sharpness).BilinearResize(width, height)

MoMask = motionmask(input,thY1=30,thY2=30,thSD=15,y=3,u=1,v=1).fity2uv().\
inflate().Levels(0, 1.0, 24, 0, 255).BilinearResize(width,height)

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, resizemask)
AddMotionblur = MaskedMerge(Addedgedsharp , MMotionblur, MoMask )

return AddMotionblur
}Note that the sharpness is used inside a Levels

What exactly is the issue with YV12Layer ?

@Mug Funky : Overlay accept YV12 as input, but AFAIK, it converts it to RGB before treating it.

Edited : small typo, plus lines too long.

jkwarras
13th February 2004, 10:57
Originally posted by FuPP
@jkwarras : you should probably use something like Peachsmoother for that purpose (excellent adaptive filtering by Linsey Dubb).


I've never tried Peachsmoother, I didn't know it's adaptive filtering (good news), I was using C3D, fluxsmooth and recently Mipsmooth. I'll take a look at this one, thanks for the tip.

Regards

Wilbert
13th February 2004, 10:58
@Mug Funky : Overlay accept YV12 as input, but AFAIK, it converts it to RGB before treating it.]a
No, it converts the clips (including the mask) to YUV 4:4:4. Btw, layer doesn't work correctly in YV12.

bond
13th February 2004, 12:04
hm i dont get it to work :(

i tried both fupps and manaos version, fupps version reports an unrecognized exception in the "MoMask = motionmask..." line, manaos one line below "inflate()..."
(btw why does manao use \ in the MoMask command but fupp doesnt?)

Manao
13th February 2004, 12:08
Bond, you have to update your version of the masktools : http://www.geocities.com/manao47/Filters/masktools-v1.4.9.zip

The \ is used in order to make a line break in the series of instructions, because my line was too long to fit the screen.

bond
13th February 2004, 12:42
thanks manao, i already had this great plugin :)

hm, maybe this is already a known issue (i have to admit i didnt search for it) but it seems the problem is caused by crop (if i comment crop() out it works)

i have a pal dvd source:
crop(2,80,716,418)
HybridFupp(640,256)

edit:
funny, with crop(0,78,720,420) or crop(2,82,716,416) it works

Manao
13th February 2004, 13:09
Your resolution is only mod 2 horizontally. It will work with mod4 resolutions. However, that was not an expected bug, thanks for reporting it. A new version should be released during the afternoon, without the bug ( if I find it ).

FuPP
13th February 2004, 23:10
Hi Manao ! Thanks a lot for your tips !

Originally posted by Manao
What exactly is the issue with YV12Layer ?

Here is a simple example (input is YV12) :

function HybridTest(clip input, int width, int height, int "sharpness", int "sh1", int "sh2")

{

Resizemask = input.edgemask(3,8,255,255,"sobel",Y=3, V=1, U=1).Inflate().Levels(0, 1.0, 24, 0, 255).\
BilinearResize(width, height).ConvertToRGB32()

MEdgesharp = Mask(input.LanczosResize(width, height).ConvertToRGB32(), Resizemask).Converttoyv12()

Resized_input = Input.Bilinearresize(width,height)

Addedgedsharp = yv12Layer(Resized_input, MEdgesharp, "add", sharpness)

return Addedgedsharp

}

This returns me an error : YV12Layer : Image formats don't match


Regards,
FuPP

bond
13th February 2004, 23:45
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?


FuPP,
can you plz tell me why you also choose to add level(), inflate(), greyscale() aso and not only used edge/motionmask and a resizefilter?

thanks :)

morsa
14th February 2004, 00:50
Any before and after images to see its effect?

FuPP
14th February 2004, 02:44
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) :



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

Inc
14th February 2004, 09:21
I can't get it work ! :(

Avisynth Vers. 2.54
Masktools: masktools_25_dll_20040110.zip

My script

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?

FuPP
14th February 2004, 10:11
You should use masktools 1.4.9

You'll find the new version here (http://www.geocities.com/manao47/Filters/masktools-v1.4.9.zip) ( As always, right click, copy adress and paste it if it doesn't work the first time )

FuPP

bond
14th February 2004, 10:14
fupp,
maybe you want to have a look at the question i posted in my last post!?

FuPP
14th February 2004, 10:54
@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

bond
14th February 2004, 11:10
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 (http://8ung.at/bond/ghosting.zip) 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

Inc
14th February 2004, 11:16
Thanks for the link - it works! Right testing now. :)

Didée
14th February 2004, 12:15
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

bond
14th February 2004, 12:50
Originally posted by Didée
Building the difference between these two frames will return a difference in *both* locations of the objectah yes of course, stupid me :D


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?

FuPP
14th February 2004, 15:29
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

mf
14th February 2004, 16:04
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 :).

pjotor
14th February 2004, 17:03
anybody know how to fix this?

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

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)

Inc
14th February 2004, 17:06
Yepp, that happened to me too, it seems that you must define "debug" in the command.

FuPP
14th February 2004, 17:24
Oops ! Forgot that in default definitions. Will fix that in next release.

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

FuPP

bond
14th February 2004, 17:39
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)

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)

bond
14th February 2004, 18:50
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?

Chainmax
14th February 2004, 20:59
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?

FuPP
14th February 2004, 21:02
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
14th February 2004, 21:05
Chainmax,

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

FuPP
14th February 2004, 21:10
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

bond
14th February 2004, 21:28
Originally posted by FuPP
Sharpness parameter comes from original Hybridresize. I can remove it if people feel it not necessary.i wondered because in your first version the sharpness value of 255 means that 100% of the edgemask is overlayed over the "soft" image
lower values would lead to a mixture of soft and edges, meaning at 128 50% of the edgemask would be soft and 50% sharpened (plz correct me if i misunderstood this)

now this isnt a bad thing of course for finetuning (would be also usable for the motionmask), tough imho the main paramters are the thresholds of the edgemask, as these define how many edges are detected and used for sharpening

3,8 came from my previous tests. I am probably going to change default 8 -> 15, and create a parameter for it.i wonder if it makes sense to define two different values
as i understand it everything under 3 is not detected as edge, over 8 is detected as edges and in between there is some transition from 0% to 100%
but i very much doubt that this transition is used. ie if i define unfilter(20,20), how much unfilter is used at a value of 5 (0,0 or 20,20 or 12,5;12,5?)?
i think 5 (or everything below 8) is not detected as 100% sharpness (meaning unfilter(0,0) gets used) and therefore it only makes sense to use the same value for both thresholds (as you did for motionmask too)
ie 8,8 would be correct for this example (plz correct me if i am wrong)

Originally posted by Chainmax
Sorry to be such a n00b, but what exactly does this filter do (in layman's terms,please)?it blurres high motion parts of a frame and sharpens the edges of the same frame

all in all i would say you can have more sharpness at the same (or even more) compressibility

What other filters (if any) is it comparable to and how does it stack up against them?there is nothing comparable to this atm i think!?

FuPP
14th February 2004, 21:39
"it only makes sense to use the same value for both thresholds"

Yep, with so weak values, you are probably right.

FuPP
14th February 2004, 22:03
Question : I don't manage to find a very good filter for moving parts. unfilter seems to be the efficient but not sufficiently, for my taste.

I've tested : edeen, dctfilter, blindpp

Any suggestions (spatial filters only...) ?

Didée
14th February 2004, 22:37
Gentlemen,

I see very much talking about unfilter() in this thread. Be careful with using unfilter()!! It is OK to be used on the whole frame; if you use it on parts of a frame only, you should be aware of what you are actually doing ...

Since ever, unfilter() has had these two side-effects:

1. It adds a tiny little amount of noise to the picture. This is not a problem.
2. It darkens the picture! :eek:

Try the following sequence on any source:

interleave(last, last.unfilter(-5,-5)).assumeFPS(4)

You'll clearly see the effect of the lightness jumping up'n down. As my rule of thumb, one should always use unfilter(h,v).lumafilter(2) to compensate for it.

Some may call me picky - but when overlaying a naked unfilter()ed frame onto another through a mask, you are altering the image in an unhomogeneous way. The effect might be hardly visible, but one should be aware of it at least.

- Didée


/wents away, rubbing his hands about the scenechange confusion ...

mf
14th February 2004, 22:45
Didee, same thing as with legacy mfToon version 0.4x and lower. My unsharp mask was pretty bad (I didn't think out of the box, or maybe I thought too much out of the box) and produced something that also darkened the image. Now normally this wouldn't be a problem, but on some instable systems the entire frame darkening would "leak" through, though it should theoretically be impossible (only happen on the cartoon edges). What resulted was a flood of bugreports on strange flickering, that I never encountered myself ;). When I finally got the issue myself I got annoyed and went out to make mfToon v0.5, which of course (:rolleyes:) fixed the issue :D.

FuPP
14th February 2004, 22:59
"2. It darkens the picture!"

Didn't know that. And Tom never fixed it ? :confused:

FuPP
14th February 2004, 23:04
This is probably stupid but I can't see the flickering effect you describe doing your test.

my version is 0.1.5, 16/01/03

:confused: again...

FuPP

Didée
14th February 2004, 23:06
It was mentioned long, long time ago - but no-one ever was bothered. Okay, mask/overlay operations were pretty seldom used by that time. And, moreover, these two effects were important parts of the solution of the "dark-blocking" puzzle. THAT was the thing bothering us ...

- Didée


[edit, after simultaneous posting]

Okay, take this! :)

stackvertical( last .coloryuv(analyze=true).subtitle("orig"),
\ last.unfilter(-5,-5).coloryuv(analyze=true).subtitle("unfilter"),
\ last.blur(.4) .coloryuv(analyze=true).subtitle("blur"))

FuPP
15th February 2004, 00:41
OK, new version

Remember : you have to load mpeg2dec3, unfilter, undot, fluxsmooth and masktools (1.4.9)
in your main script for this to work.

1/ Parameters

input : your clip
width : x for resizing
height : y for resizing
E_Thr (0..255) : Edge detection threshold
sharp_x (-100..100) : horizontal sharpening strength
sharp_y (-100..100) : vertical sharpening strength
M_Thr (0..255) : motion detection threshold
M_SCD (0..255) : scene change detection threshold (used for motion detection)
chroma (true/false) : will smooth chroma
dering (true/false) : will... dering
debug (0, 1 or 2) : display edge detection or motion maps

all are optional except width and height


defaults :

E_Thr : Default = 15
sharp_x : Default = 40
sharp_y : Default = 12
M_Thr : Default = 30
M_SCD : Default = 17
chroma : Default = true
dering : Default = false
debug : Default = 0 (no debug)

syntax :

HybridFupp(clip , int width, int height, int E_Thr, int sharp_x, int sharp_y, int M_Thr, int M_SCD,
bool chroma, bool dering, int debug)

example :

hybridFupp(448,320,12,30,9,32,15,true,true,0)

to show motion mask : hybridFupp(448,320,debug=2)
to show edge mask : hybridFupp(448,320,debug=1)


2/ the Avsi file

See first post for download

Code is now here for info



Function HybridFupp(clip input, int width, int height, int "E_Thr", int "sharp_x",\
int "sharp_y", int "M_Thr", int "M_SCD", \
bool "chroma", bool "dering", int "debug")

{
global input = input
global width = width
global height = height
global E_Thr = E_Thr
global sharp_x = sharp_x
global sharp_y = sharp_y
global M_Thr = M_Thr
global M_SCD = M_SCD
global chroma = chroma
global dering = dering

E_Thr = Default(E_Thr, 15)
M_Thr = Default(M_Thr, 30)
M_SCD = Default(M_SCD, 17)
sharp_x = Default(sharp_x, 40)
sharp_y = Default(sharp_y, 12)
chroma = Default(chroma, true)
dering = Default(dering, true)
debug = Default(debug, 0)

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

Frame = (debug == 1) ? MaskedMerge(input.Bilinearresize(width, height), Blank, RM(input, width, height, E_Thr)) \
: (debug == 2) ? MaskedMerge(input.BilinearResize(width, height), Blank, MM(input, width, height, M_Thr, M_SCD)) \
: FuPP(input, width, height, E_thr, sharp_x, sharp_y, M_Thr, M_SCD, chroma, dering)

return Frame
}

function FuPP(clip input, int width, int height, int "E_Thr", int "sharp_x", int "sharp_y", int "M_Thr", int "M_SCD", \
bool "chroma", bool "dering")
{

input = input.undot()

input = (chroma == true) ? input.blindpp(quant=16, cpu2="ooxxox", moderate_h=10, moderate_v=20) : input
input = (dering == true) ? input.blindpp(quant= 2, cpu2="ooooxo", moderate_h=30, moderate_v=50) : input

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

Soft = input.BilinearResize(width, height)

MEdgesharp = input.LanczosResize(width, height).unfilter(sharp_x, sharp_y).lumafilter(2)
MMotionblur = soft.unfilter(-5, -5).lumafilter(2)

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

return AddMotionblur
}

function RM(clip i,Int w,Int h, Int e_th)
{

ResizeMask = EdgeMask(i, 0, e_th, 255, 255, "sobel", Y=3, V=1, U=1).Inflate().BilinearResize(w, h)
return ResizeMask
}

function MM(clip i,Int w,Int h, Int m_th, Int scd)
{

MoMask = MotionMask(i, thY1= m_th, thY2= m_th, thSD= scd, y=3, u=1, v=1).Inflate().BilinearResize(w, h)
return MoMask
}




Any feedback about quality and compression would be really appreciated

Cheers,

FuPP

edit : typos + Motion SCD default changed to 17, dering default to false

bond
15th February 2004, 12:13
thanks didée for pointing out the unfilter darkening!

i played around with the lumafilter, and in my sample lumafilter(2) lightened up the frame too much, 1 would match the source better here :B

but all in all the question is:
does this high-mo/edges darkening hurt the quality? does it hurt the codec doing his job as it should? or are there any other potential problems?

what other good and fast (!) spatial smoothing (i dont do sharpening) filter can be recommended for useage?


another question are the thresholds of the edgemask: EdgeMask(0, e_th, 255, 255)
i would be interested if someone can say if the part between 0 and e_th is used for edgetreatement or not in fupps script?
and if yes, how?