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 24th September 2021, 11:48   #401  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,500
Quote:
Originally Posted by Dogway View Post
The range expansion is only for the motion vectors
Oh, wow, thanks. Why didn't you default to 0? Perhaps not everybody wants the video to be "touched" on the dark parts.

Please, give me a hint: some movies, such as Transformers saga, has too much sharpness, giving really low compressibility ratio. FranceBB suggested me to use some vertical only MedianBlur or Blur.

What kind of command would you suggest me from your ex_plugins? And should it be applied before or after denoising?
__________________
@turment on Telegram

Last edited by tormento; 24th September 2021 at 11:53.
tormento is online now   Reply With Quote
Old 24th September 2021, 12:06   #402  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,351
I need to see what kind of sharpness. If there isn't any overshoots a simple blur before denoising can do ( ex_boxblur(mode="weighted") with 0.5 or 0.3 value ) passed through an edge mask or even ex_smooth() but -had an idea- needs limiting. If source has overshoots (ringing or halo) you might need to use a FIR filter as once cretindesalpes pointed to me, read here for FIR filtering.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread
Dogway is offline   Reply With Quote
Old 24th September 2021, 12:16   #403  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,500
Quote:
Originally Posted by Dogway View Post
I need to see what kind of sharpness
A clip is enough?

And what about str=0 vs str=3 as default?
__________________
@turment on Telegram
tormento is online now   Reply With Quote
Old 24th September 2021, 12:19   #404  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,351
Default is Str=3 because most sources benefit from a slight bump in dark areas. Clips that might not benefit as much are generally sports, TV programs which are tuned for a bright surround viewing environment.

Yes, small clip is enough. I will try to bench ex_smooth() against it.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread
Dogway is offline   Reply With Quote
Old 24th September 2021, 17:35   #405  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,500
Quote:
Originally Posted by Dogway View Post
Yes, small clip is enough. I will try to bench ex_smooth() against it.
Here it is.

Object countours are insanely sharp, just look at sides of houses, cars and robots.

FranceBB knows the issue and solved it with some blur.
__________________
@turment on Telegram
tormento is online now   Reply With Quote
Old 24th September 2021, 18:16   #406  |  Link
FranceBB
Broadcast Encoder
 
FranceBB's Avatar
 
Join Date: Nov 2013
Location: Royal Borough of Kensington & Chelsea, UK
Posts: 2,840
Quote:
Originally Posted by tormento View Post
FranceBB knows the issue and solved it with some blur.
Yes I do and yes I did.
I work in post production and this generally happens with some rather sharp shots. What happens is that when I get a shot from like a Drone or even a downscaled shot from a 4K camera to FULL HD 50p and I divide it in fields to get 25i I always always always get aliasing. Even if I get 25p materials and I leave them like that and I just flag them as interlaced (so they're progressive) I still have aliasing.
For this very reason I always always always suggest to blur vertically only a bit to avoid aliasing.

blur(0, 1)

Works.

See this: https://forum.doom9.org/showthread.php?p=1875091
FranceBB is offline   Reply With Quote
Old 24th September 2021, 18:54   #407  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,500
@Dogway, is it correct that setting contrasharp=true, it requires RGTools? I was almost sure that you put removegrain into ex_tools.
__________________
@turment on Telegram
tormento is online now   Reply With Quote
Old 24th September 2021, 20:42   #408  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,500
Quote:
Originally Posted by FranceBB View Post
blur(0, 1)
Plain and simple

Let's see what Dogway will pull out of the hat.
__________________
@turment on Telegram
tormento is online now   Reply With Quote
Old 24th September 2021, 21:30   #409  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,351
Yes, sorry I didn't have time to check it (battle in RGB to HSV conversion!), but I tweaked Savitzky-Golay smoothing filter a few hours ago to remove haloes. I even added clamp to ex_luts but that will be uploaded in the next few days.
Code:
function ex_smooth(clip a, int "radius", int "radiusV", bool "sharp", bool "limit", string "mode", int "UV", bool "fulls") {

    rgb  = isRGB(a)
    isy  = isy(a)
    bi   = BitsPerComponent(a)

    rd = Default(radius,  1)            # from 0 to 3
    rv = Default(radiusV, rd)           # from 0 to 3
    sh = Default(sharp, false)          # Sharp version of S-G mode
    lm = Default(limit,    sh)          # Enable limiting for Sharp smoothing
    md = Default(mode,  "SG")
    UV = Default(UV,    rgb ? 3 : 1)
    fs = Default(fulls, rgb)
    rd = max(rd, 0)
    rv = max(rv, 0)

    rd == 3 || rv == 3 ? Assert (!sh, "S-G Sharp mode only supports radius < 3")                    : nop()
    md == "SNN"        ? Assert (rd == rv && rd < 2 && rv < 2, "SNN mode only supports radius < 2") : nop()

    if (!sh) {

    # Quadratic/Cubic (2nd and 3rd degree polynomials)
    strv = rv == 1 ? "x[0,1] x[0,-1] + 4 * x[0,0] 5.666666666 * + x[0,-2] x[0,2] + - 0.085714286 *"                                                                 : \
           rv == 2 ? "x[0,1] x[0,-1] + 2 * x[0,0] 2.333333333 * x[0,-2] x[0,2] + + + x[0,-3] x[0,3] + 0.666666666 * - 0.142857143 *"                                : \
           rv == 3 ? "x[0,3] x[0,-3] + 4.666666666 * x[0,2] x[0,-2] + 13 * x[0,1] x[0,-1] + 18 * x[0,0] 19.666666666 * + + + x[0,-4] x[0,4] + 7 * - 0.012987013 *"  : ""

    strh = rd == 1 ? "x[-1,0] x[1,0] + 4 * x[0,0] 5.666666666 * + x[2,0] x[-2,0] + - 0.085714286 *"                                                                 : \
           rd == 2 ? "x[-1,0] x[1,0] + 2 * x[0,0] 2.333333333 * x[2,0] x[-2,0] + + + x[3,0] x[-3,0] + 0.666666666 * - 0.142857143 *"                                : \
           rd == 3 ? "x[3,0] x[-3,0] + 4.666666666 * x[2,0] x[-2,0] + 13 * x[1,0] x[-1,0] + 18 * x[0,0] 19.666666666 * + + + x[-4,0] x[4,0] + 7 * - 0.012987013 *"  : ""

    } else {

    # Quartic/Quintic (4th and 5th degree polynomials) (sharper)
    strv = rv == 1 ? "x[0,1] x[0,-1] + 15 * x[0,0] 26.2 * x[0,3] x[0,-3] + + + x[0,-2] x[0,2] + 6 * - 0.021645022 *"                                                : \
           rv == 2 ? "x[0,2] x[0,-2] + 2 * x[0,1] x[0,-1] + 9 * x[0,0] 11.933333333 * x[0,4] x[0,-4] + + + + x[0,-3] x[0,3] + 3.666666666 * - 0.034965035 *"        : ""

    strh = rd == 1 ? "x[1,0] x[-1,0] + 15 * x[0,0] 26.2 * x[3,0] x[-3,0] + + + x[-2,0] x[2,0] + 6 * - 0.021645022 *"                                                : \
           rd == 2 ? "x[2,0] x[-2,0] + 2 * x[1,0] x[-1,0] + 9 * x[0,0] 11.933333333 * x[4,0] x[-4,0] + + + + x[-3,0] x[3,0] + 3.666666666 * - 0.034965035 *"        : ""

    }

    strv = md == "SNN" ? "x[0,0] X@  x[-1,1] A@ - abs X x[1,-1]  H@ - abs + M@
                          X          x[0,1]  B@ - abs X x[0,-1]  G@ - abs + N@ min
                          X          x[1,1]  C@ - abs X x[-1,-1] F@ - abs + O@ min
                          X          x[-1,0] D@ - abs X x[1,0]   E@ - abs +    min W^
                          W M == A H + W N == B G + W O == C F + D E + ? ? ? 0.500001 *" : strv

    rv == 0 ?      a                                                                  : \
    isy     ? Expr(a,    strv                                                       ) : \
    UV == 1 ? Expr(a,    strv, ""                                                   ) : \
              Expr(a,    strv, ex_UVexpr(strv, UV, bi, rgb, fs), scale_inputs="none")
    rd == 0 || md == "SNN" ? last                                                     : \
    isy     ? Expr(last, strh                                                       ) : \
    UV == 1 ? Expr(last, strh, ""                                                   ) : \
              Expr(last, strh, ex_UVexpr(strh, UV, bi, rgb, fs), scale_inputs="none")

	lm && sh ? ex_clamp(last,a.ex_expand(min(1,rd),"horizontal").ex_expand(min(1,rv),"vertical"),a.ex_inpand(min(1,rd),"horizontal").ex_inpand(min(1,rv),"vertical"),0,0) : last

	# ex_luts(last,a,mode="clamp",UV=uv) performance update in the next few days
}
Call like "ex_smooth(1 or 2, sharp=true, limit=true)"
If it's only vertical I guess "ex_smooth(0, 1, sharp=true)" can do.
EDIT: SantiagMod also works very good. But I see there's some ringing in the source.

EDIT2: Some alternatives:
Finedehaloer
Code:
SantiagMod(strh=2,strv=2)
a=last
ex_luts(last,last.removegrain(12,0),mode="clamp",UV=1)
ex_lutxy(last,a,"x y - abs 7 > y x y min ?")
# ex_boxblur(0.15,mode="weighted") # optional
FIR:
Code:
deconv_h = "0 -5 25 100 25 -5 0 "
mt_convolution (deconv_h, deconv_h, Y=3, U=2, V=2)
Quote:
Originally Posted by tormento View Post
@Dogway, is it correct that setting contrasharp=true, it requires RGTools? I was almost sure that you put removegrain into ex_tools.
ExTools do have counterpart filters of RGTools, but is not SO hellish fast (90% there still), so SharpenersPack is in MIX mod. I should probably place it inside the MIX mods folder.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread

Last edited by Dogway; 24th September 2021 at 23:19.
Dogway is offline   Reply With Quote
Old 25th September 2021, 00:59   #410  |  Link
anton_foy
Registered User
 
Join Date: Dec 2005
Location: Sweden
Posts: 702
Sorry but what is ex_smooth? The purpose? HSV conversion sounds very interesting! Just wondering because of the way I try to make my filters.
anton_foy is offline   Reply With Quote
Old 25th September 2021, 01:46   #411  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,351
A smoothing filter, between antialiasing and blur. I just added a limiter because it was creating some 2nd order halos.

Yes, HSV conversion is proving to be more complex than I thought. There are better cylindrical models and easier to implement but I want to add HSV to TransformPack for completion and also comparison for the Skin_qualifier()
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread
Dogway is offline   Reply With Quote
Old 25th September 2021, 02:21   #412  |  Link
anton_foy
Registered User
 
Join Date: Dec 2005
Location: Sweden
Posts: 702
Interesting indeed although I must check into "skin_qualifier", guess that the name says it all? Please shout out if you get to finish the hsv-conversion you mentioned a while ago. I would love to try to base a denoising filter off of that colorspace.

Last edited by anton_foy; 25th September 2021 at 02:25.
anton_foy is offline   Reply With Quote
Old 25th September 2021, 11:17   #413  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,500
Quote:
Originally Posted by Dogway View Post
Yes, HSV conversion is proving to be more complex than I thought. There are better cylindrical models and easier to implement but I want to add HSV to TransformPack for completion and also comparison for the Skin_qualifier()
So you suggest me to wait for the definitive version?
__________________
@turment on Telegram
tormento is online now   Reply With Quote
Old 25th September 2021, 19:49   #414  |  Link
wonkey_monkey
Formerly davidh*****
 
wonkey_monkey's Avatar
 
Join Date: Jan 2004
Posts: 2,484
Moved from the Avisynth+ discussion:

Code:
"x 0 > y x / atan A@ x 0 < y 0 >= & A pi + x 0 < y 0 < & A pi - x 0 == y 0 > pi 0.5 * y 0 < pi -0.5 * 0 0 ? ? ? ? ? ?"
I think there's some things wrong with this. If you map it to pixel coordinates (with suitable multiplication and offset) you get this:


Note the vertical line.

Separately, the deepest conditional seems to be:

Code:
pi -0.5 * 0 0 ?
Which will always equate to zero.

While attempting to find an alternative, I've got as far as

Code:
y x / atan

dup pi - x 0 < swap2 ?

dup 2 pi * + x 0 < y 0 > & swap2 ?
though it seems to still work even when x should be 0 (I used sx instead as a pixel coordinate), which makes no sense to me.

I use "swap2 ?" for conditionals because to me it makes far, far more sense to have the condition last.
__________________
My AviSynth filters / I'm the Doctor
wonkey_monkey is offline   Reply With Quote
Old 25th September 2021, 22:59   #415  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,351
Thanks for looking into it. I found the error was at the first conditional, changing it to ">=" fixes the line issue (despite originally being ">" in the wiki).

The first 0 stands for "undefined" when all the ternaries fail, and the last 0 when "x < 0" (first conditional) which seems wrong because following we have "minus than 0" comparisons, so might need to reorder the ternaries.

I implemented the compact version and also works.
Code:
ex_lutspa(mode="absolute", expr="x 255 - X@ 0 > y 255 - Y@ X / atan A@ Y 0 > pi 0.5 * X Y / atan B@ - Y 0 < 0 B - pi 0.5 * - X 0 < A pi + X 0 == Y 0 == & 0 0 ? ? ? ? ? pi 180 / * 2048 * 128 +", UV=128)

And another one without conditionals (only for the sign(x) operator):
Code:
ex_lutspa(mode="absolute", expr="x 255 - X@ 0 == 0 x dup abs / ? SX^  y 255 - Y@ 0 == 0 y dup abs / ? SY^  SX dup * Y X / atan *   1 X 0 < -1 1 ? - 0.5 *    SY dup dup * - 1 + * pi * +   pi 180 / * 4096 *", UV=128)
Improved (maybe) and much faster:
Code:
ex_lutspa(mode="absolute", expr="x 255 - X^   y 255 - Y^    X dup abs / SX^   Y dup abs / SY^   SX dup * Y X / atan *   1 SX - 0.5 *    SY dup dup * - 1 + * pi * + 180 pi / * 128 + ", UV=128)
Please forgive my awkward normalization, I don't know what I'm doing lol

@tormento: yes, wait for the improved "HSV". I already implemented IPT model in other projects, it's miles better than HSV as it is UCS (uniform color space) in the HUE domain. But I need HSV to correlate skin HUE on HSV (33.5) to IPT.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread

Last edited by Dogway; 25th September 2021 at 23:37.
Dogway is offline   Reply With Quote
Old 26th September 2021, 08:56   #416  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,500
Quote:
Originally Posted by Dogway View Post
@tormento: yes, wait for the improved "HSV".
In your opinion, would I lose more details and general quality using some light vertical blur or increasing from tr=3, thsad=300 to tr=4, thsad=400?
__________________
@turment on Telegram
tormento is online now   Reply With Quote
Old 26th September 2021, 11:01   #417  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,351
I didn't spot any staircasing so vertical blur seems very destructive to me.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread
Dogway is offline   Reply With Quote
Old 26th September 2021, 14:45   #418  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,500
Quote:
Originally Posted by Dogway View Post
I didn't spot any staircasing so vertical blur seems very destructive to me.
Staircasing?
__________________
@turment on Telegram
tormento is online now   Reply With Quote
Old 26th September 2021, 14:59   #419  |  Link
Dogway
Registered User
 
Join Date: Nov 2009
Posts: 2,351
A type of aliasing.

EDIT: By the way:

Quote:
Originally Posted by tormento View Post
Can't you use Taylor series? Usually with 5/6 terms you have very good approximation.
Wow, had no idea of it. At some point I searched for optimizing exponent operator and found nothing. This is a game changer. I tried though to implement to ex_contrast() without success, these days I'm a bit slow (fatigue...)
Code:
cont   = 5.0
pivot  = 0.5

knee   = 1. / (1. + exp(cont *  pivot))
shldr  = 1. / (1. + exp(cont * (pivot - 1.)))
shmkn  = shldr - knee
rshmkn = 1. / shmkn

# 'exp' Taylor series
exp    = "X@ X 2 ^ 0.500001 * + X 3 ^ 0.166666666 * + X 4 ^ 0.041666666 * + 1 +"
Expr(last, Format("1 1 {cont} {pivot} x ymin - ymax ymin - / - * "+exp+" + / {knee} - {rshmkn} * ymax ymin - * ymin +"), "")
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread

Last edited by Dogway; 27th September 2021 at 01:02.
Dogway is offline   Reply With Quote
Old 26th September 2021, 16:19   #420  |  Link
tormento
Acid fr0g
 
tormento's Avatar
 
Join Date: May 2002
Location: Italy
Posts: 2,500
Quote:
Originally Posted by Dogway View Post
Wow, had no idea of it.
I am really happy to be of help to one of the few who have helped us all!
__________________
@turment on Telegram

Last edited by tormento; 27th September 2021 at 15:30.
tormento is online now   Reply With Quote
Reply

Tags
avisynth, dogway, filters, hbd, packs

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 20:16.


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