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 17th September 2019, 03:05   #1  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Uglarm - Logo Interpolator/Blurrer v0.0 - 17 Sept 2019

Uglarm v0.0, logo blurring filter --- by StainlessS @ Doom9.
Req: VS 2008 Runtimes.

Guinea pigs required.

Code:
Uglarm v0.0, logo blurring filter  --- by StainlessS @ Doom9.

  Filter for blurring a logo, using LogoAway style Uglarm Interpolation method.
    Logo pixels interpolated from all non-clipped pixels surrounding the logo area,
    nearer pixels have more effect (governed by BlurPower).


Function Uglarm(clip c,                                             [* Avs v2.58 & v2.60 std supports YV12/YUY2/RGB32/RGB24 : Avs+ r2915+ also YV16, YV12, YV24, Y8 *]
        \ int LogoX,int LogoY,Int LogoW,Int LogoH,                  [* ALL coords can be -ve, where RHS/BOT relative, LogoW & LogoH can additionally be 0 where RHS/BOT relative*]
        \ int "ClipX"=0,int "ClipY"=0,Int "ClipW"=0,Int "ClipH"=0,  [* ClipW, and ClipH coords can be zero or -ve, where RHS/BOT relative (but ClipX:ClipY cannot be -ve) *]
        \ float "SAR"=1.0,                                          [* Sample (Pixel) Aspect Ratio. SAR < 1.0:=Pixels are taller than wide, 1.0 < SAR:- pixels are wider than tall, SAR==1.0:=Pixels are square. *]
        \ float "BlurPower"=3.0,                                    [* 0.0 -> 10.0. 0.0=Single color Average of perimeter pixels, 10.0 Perimeter pixels nearest logo pixel greatest effect. Suggest about 3.0 *]
        \ Int "ShowMode"=2                                          [* 0=Overlay Logo Patch(Clipped Logo), 1=Overlay Logo Patch(Clipped) & Border, 2=DeLogo, 3=KeepChroma(Luma only), 4=KeepLuma(ChromaOnly) *]
        \ Bool "Blank"=false                                        [* Where ShowMode==2 and Blank==True then Blank to Black any border area (border is outside of Clip args) *]
        \ )


        LogoX,LogoY,LogoW,LogoH,            Define Logo area. ALL coords can be -ve, where RHS/BOT relative, LogoW & LogoH can additionally be 0 where RHS/BOT relative*]

        ClipX,ClipY,ClipW,ClipH,            All default 0, being full frame (as crop). Inside Clip area is normal unclipped frame,
                                                outside is border/lettrbox area (avoid using border as source pixels for blurring).
                                                ClipW, and ClipH coords can be 0 or -ve, where RHS/BOT relative.

        SAR,                                Default 1.0. Range 0.0 < SAR <= 10.0. Aspect Ratio of pixel(x/y).
                                                Automatically adjusts SAR for chroma of YV16 and YUY2 (otherwise you would get vertical chroma lines for YUY2 and YV16).

        BlurPower,                          Default 3.0. Range 0.0 <= BlurPower <= 10.0. 0.0=Average of all perimeter pixels (all perimeter pixels given equal weight).
                                                The greater BlurPower, the more the NEAREST perimeter pixels affect logo pixels result during logo interpolation.

        ShowMode,                           Default 2. (Normal Delogo)
                                                0 = Show Overlay Patch (Clipped Logo) Area. # For Setting up Filter.
                                                1 = 1=Overlay Logo Patch(Clipped) & Border. #   Ditto.
                                                2 = Normal Delogo.
                                                3 = KeepChroma, Luma   blur only (No effect if not YUV, as for Showmode=2).
                                                4 = KeepLuma, Chroma blur only (No effect if not YUV, as for Showmode=2).  [EDIT: was LumaChroma ???]

                                                    For ShowMode 0 and 1, we use Layer filter and pre (some version of) Avs+ Avisynth, we need to convert to either YUY2 or RGB32 if not those colorspaces..
                                                        YV12 will be converted to YUY2, and RGB24 to RGB32. Both types are then converted back to original colorspace befre return from filter.
                                                    For Modes 2,3 and 4, Avisynth 2.60 can additionally use YV16, YV12, YV24, Y8.
                                                    Avs+ (after some version) can use all Avs 2.60 standard colorspaces in all ShowModes with exception of YV411 which is not supported ALL ALL. [EDIT: Should be AT ALL]

        Blank,                              Default False. If True, and ShowMode >= 2, then will blank any Clipped border area to black (via Clip args).




UGLARM Code derived from here (ffdshow-tryout) :- https://sourceforge.net/p/ffdshow-tryout/code/HEAD/tree/trunk/src/imgFilters/TimgFilterLogoaway.cpp
Although original source from VirtualDub's LogoAway seems unobtainable.

ffdshow-tryout  (c) 2004-2006 Milan Cutka, Based of Logoaway plugin filter for VirtualDub by Krzysztof Wojdon (c) 2000-2001.

Original VirtualDub LogoAway filter docs by Krzysztof Wojdon :- http://vander.wojdon.net/virtualdub/ladocs301/logoaway.html
See MediaFire in my sig below.
3 Dll's for avs v2.58, avs/+ v2.60 x86/x64.
+ Source + full VS 2008 Project files.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 23rd September 2019 at 10:20.
StainlessS is offline   Reply With Quote
Old 17th September 2019, 03:09   #2  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Code:
WH=4
A=BlankClip(width=WH,height=WH) B=A.Invert StackHorizontal(A,B) StackVertical(Invert) trim(0,-1)
#ConvertToRGB24
#ConvertToRGB32
ConvertToYUY2
#ConvertToYV12
#ConvertToYV16
#ConvertToYV24
#ConvertToY8
ORG=Last
trim(0,-1)

LogoW    = Width/2
LogoH    = Height/2

LogoX    = (Width-LogoW)/2
LogoY    = (Height-LogoH)/2

ClipX    =  0    # Black border area, +ve ONLY
ClipY    =  0    #   ditto
ClipW    =  0    #   Can be -ve, Width  relative
ClipH    =  0    #   Can be -ve, Height relative

SAR       = 1.0
BLURPOWER =  3.0
SHOWMODE  =    2
BLANK     =  False

Uglarm(LogoX,LogoY,LogoW,LogoH,ClipX,ClipY,ClipW,ClipH,SAR,BlurPower,ShowMode,BLANK)

PointResize(512,512)
Pre-Blur (Full Image 8x8 pixels)


Post Blur (Full Image 8x8 pixels)


Post Blur (Full Image 64x64 pixels)


Code:
WH=32
#CS="RGB24"
#CS="RGB32"
#CS="YUY2"
CS="YV12"
#CS="YV16"
#CS="YV24"
#CS="Y8"
A=BlankClip(Pixel_Type=CS,width=WH,height=WH,Color=$E6AF42)
B=A.Invert
C=StackHorizontal(A,B)
D=StackHorizontal(B,A) StackVertical(C,D) trim(0,-1)
trim(0,-1)

LogoW    = Width/2
LogoH    = Height/2

LogoX    = (Width-LogoW)/2
LogoY    = (Height-LogoH)/2

ClipX    =  0    # Black border area, +ve ONLY
ClipY    =  0    #   ditto
ClipW    =  0    #   Can be -ve, Width  relative
ClipH    =  0    #   Can be -ve, Height relative

SAR       =  1.0
BLURPOWER =  3.0
SHOWMODE  =    2
BLANK     =  False

Uglarm(LogoX,LogoY,LogoW,LogoH,ClipX,ClipY,ClipW,ClipH,SAR,BlurPower,ShowMode,BLANK)

PointResize(512,512)

return last #.Info
Pre-Blur (Full Image 64x64 pixels)


Post Blur (Full Image 64x64 pixels)
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 17th September 2019 at 04:55.
StainlessS is offline   Reply With Quote
Old 17th September 2019, 08:34   #3  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Nuther example, cropped corner (320x320) of Tears Of Steel frame, with fake logo in black. [frame 4865]

Black logo


Uglarm


EDIT: What it originally looked like


EDIT: Now with added top border, and changed to fake logo in red.


And fixed again, setting ClipY. [ removes the red logo and no import of black rubbish from border]


And as above, but with Blank=true
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 17th September 2019 at 08:56.
StainlessS is offline   Reply With Quote
Old 17th September 2019, 17:36   #4  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,078
Quote:
Originally Posted by StainlessS View Post
Guinea pigs required.
Sure, here's your first guinea pig...

Get my test results here:
https://we.tl/t-sZZD7vAp4i

Some remarks:
The algo seems to be close to the original LogoAway filter. I did notice a difference in the Blur Power parameter. In the LogoAway version 4.01 this parameter was renamed to "Exponent Power", no idea what was changed in the code. But with LogoAway the max value for this param delivered the best looking results. Very different in your Uglarm plugin. Blur Power 3 looks way better than the max value of 10.

Speed comparison showed that your Uglarm plugin is on a par with the InpaintDelogo Turbo modes. Using InpaintDelogo without Turbo makes it almost 20% slower. And for visual quality the Inpaint plugin is in no danger to be surpassed by the Uglarm algo. Even the fastest turbo mode 1 looks much better to me than any other contenders.


Cheers
manolito
manolito is offline   Reply With Quote
Old 17th September 2019, 19:36   #5  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
"BlurPower" was objectional to some, so they came up with a more Politically Correct name [well mathematical] , or something. I really dont give a monkey's
either way (No offence wonkey), I can rename it to whatever you might prefer, nothing I think changed in the code, wording only.
Max value of 10, is in no way useful, but you gotta stop somewhere, I did try 100.0, worked, then 1000.0, green logo, so I did
not feel 'safe' having to stop at 100.0, so reduced to 10.0. BlurPower less than 1.0 is also not really useful, however, 0.0 produces
simple average of perimeter pixels , so for that alone I chose to limit base at 0.0. [Any number <except 0> ^ 0.0 = 1.0]
(The Exponent power thing is discussed in the first link I gave for ffmpeg Patch thingy, probably where rename saw light of day).

And thanks for taking the time to put forth you opinion, as always, I never take any notice .

EDIT: How does the competition cope with borders ? (as in the red logo, black border thing earlier in this thread). [that alone is likely a fairly big hit on speed].

EDIT: Fact is, I aint even tried VDX InpainLogo thing, I got gazillions of things in my in-box and have not as yet tried it. I wanted something that
could basically replace s_ExLogo(), and my offering is the best that I can do (first time around).
Good on-ya VDX, I is gonna try it soon, really. [It is not a competition, if VDX whollops the shit out of what I released, then I is also happy
(but not maybe quite as happy as if mine kicked the shit out of his)]

EDIT: I'm a little upset, beer was a bit cloudy today. {I guess that there is always tomorrow - and on that subject,
User TomArrow needs to change his name, I always get a picture [with full choral background] of the musical Annie, when I see his name,
change your name Tom, its a tad distracting - you know it makes sense ]
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 18th September 2019 at 14:35.
StainlessS is offline   Reply With Quote
Old 18th September 2019, 12:06   #6  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
Originally Posted by manolito View Post
But with LogoAway the max value for this param delivered the best looking results. Very different in your Uglarm plugin. Blur Power 3 looks way better than the max value of 10.
InpaintDelogo thread:- https://forum.doom9.org/showthread.p...10#post1884710
From the ffdshow source (linked in InpaintDelogo thread):- https://sourceforge.net/p/ffdshow-tr...erLogoaway.cpp

Code:
void TimgFilterLogoaway::Tplane::calcUweWeightTable(int w, int h, int power)
{
    double e = 1.0 + (0.3 * power);
    int x;
    for (x = 0; x < w; x++)
        for (int y = 0; y < h; y++)
            if (x + y != 0) {
                double d = pow(sqrt(double(x * x + y * y)), e);
                uwetable[x + y * w] = 1.0 / d;
            } else {
                uwetable[x + y * w] = 1.0;
            }
Max value for power in LogoAway 4.01 is 10, so
above "double e = 1.0 + (0.3 * power)" would put e at 1.0 + (0.3*10) = 4.0, so
Uglarm(BlurPower=4.0) should be exactly same as LogoAway:Uglarm(Exponent_Power=10) .
I can change default BlurPower in Uglarm to 4.0, if you like, and maybe "BlurPower" to eg "ePower" or "expPower", or something else if you prefer.

EDIT: Note, minimum for Uglarm BlurPower is 0.0, whereas is 1.0 for LogoAway, so LogoAway cannot do the BlurPower=0.0 single color average of all perimeter pixels thing
that Uglarm allows. Allowing BlurPower=10.0, is of course overkill, but is better to allow extremes for whatever reason user may have, [special effects or whatever]
and not limit to the best possible (in your opinion) value. [so we deliberately do not exactly follow the LogoAway limits]
EDIT: By the way, for some clips I thought that BlurPower = 5.0, (or even 7.0 for others) was the better option, of course those are not an option in LogoAway with limit @ 4.0.
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 18th September 2019 at 12:42.
StainlessS is offline   Reply With Quote
Old 18th September 2019, 19:14   #7  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 3,078
Thanks for the explanation of the expPower param. And yes, using a value of 4 gives a practically identical result to LogoAway with the slider all the way to the right.

I have totally switched over to InpaintDelogo on my ThinkPad notebooks. The blurred logo is much less intrusive, maybe because it uses a mask, so the rectangular logo area from LogoAway and Uglarm is absent.

And for my ancient desktop computer where I cannot use the Inpaint plugin at all (probably needs SSE2) I will stick with LogoAway. The way to set up the params in VDub is much more intuitive to me than having to edit the AVS script and then reopen the preview only to see that my edited params did not do it.
manolito is offline   Reply With Quote
Reply

Tags
delogo, logo

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 14:28.


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