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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 13th May 2010, 23:26   #1  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,957
s_ExLogo v1.1 Logo Removal - Dekafka Mod

Code:
#------------------------------------------------------------------------
#                s_ExLogo() v1.1, De-logo Function, With Clipping
#                                by StainlessS
#
# http://forum.doom9.org/showthread.php?t=154559
#------------------------------------------------------------------------
# History:
#
# v1.0 Initial release, featuring Lousy coordinate calculations. 
# v1.1 15 Sept 2010: Fixed haphazard coord calcs + lots of other alterations.
#      More like what v1.0 should have been, with more rigorous error checking and reporting.
#      SPow now 2.2 by default as in pre-release v0.0
#------------------------------------------------------------------------
#
# ("s_" Just Means Script Function)
#
# Filter requirements:- NONE (Tested only on Avisynth v2.5.8 and v2.6)
#
# Based on Dekafka (YUY2 Only)
#
#  HHHHHH         s_Exlogo, samples above and below (shown left as 'H')
# VLLLLLLV        and combines them into a horizontal bar.
# VLLLLLLV        Samples left and right and combines them into a vertical bar (show as 'V'.
# VLLLLLLV        Logo area shown as 'L'.
# VLLLLLLV        These bars may or may not be blurred, and are then resized to fit
#  HHHHHH         the logo area. The resized bars are then mixed together based
#                 on arg "Spow" and the ratio of length of Vertical bars to length
#                 of horizontal bars. Finally, the resultant de-logo'd area is
#                 Layer'ed onto the clip using the Amount arg.
#                   Clipping can be set so as to avoid eg sampling letterboxing when
#                 blurring out the logo (would normally result in nasty black
#                 block instead of a nasty logo). 
#
#  Basic usage:-
#   s_ExLogo(clip, int LogoX, int LogoY, int LogoW, Int LogoH)
#
#     LogoX,LogoY,LogoW,LogoH, position of logo, width and height (Compulsory args)
#         LogoX, LogoY, Sets upper left position of logo rectangle.
#         LogoW, LogoH, Width and height of Logo rectangle,
#            Zero and -ve, values can be used, relative to the width and height,
#            (as used in crop)
#            s_ExLogo(Last,680,520,-4,-4) would set logo area to (680,520,36,52)
#              on a 720x576 clip.
#         LogoX and LogoW should be in even numbers only (YUY2).
#
#  Optional args
#     int LogoMode, 0-4, Default 2.
#         0 = Show LOGO position by dimmed rectangle. (initial logo setup)
#         1 = Show PATCH (CLIPPED logo) position & Clipping. NON CLIPPED area shown in GREEN.
#             Clipping setup, Used AFTER LogoMode=0 (Initial Logo Setup).
#         2 = Normal, Default.
#         3 = Keep Chroma (delogo Luma only)
#         4 = Keep Luma (delogo Chroma only)
#
#     int BlurMode, 0-6, Default 4, Sets Both HBlur and VBlur as below.
#         0 = 0.0,  Off, No Blurring, BilinearResize only. (maybe subtitles)
#         1 = 0.2
#         2 = 0.33
#         3 = 0.5
#         4 = 1.0  Default
#         5 = 1.58 Maximum possible
#         6=  1.0  User Defined. (defaults to 1.0 here, as HBlur & VBlur, default 1.0)
#
#     int HBlur, Int VBlur, Default 1.0
#         Set by BlurMode or user defined if BlurMode = 6.
#         HBlur controls amount of Horizontal blurring in Vertical bars.
#         VBlur controls amount of Vertical blurring in Horizontal bars.
#
#     int ClipX, ClipY,ClipW,ClipH, Clipping rectangle, All default 0
#         As used in crop.
#         ClipX, ClipY, Sets upper left position of clipping rectangle.
#         ClipW, ClipH, Width and height of clipping rectangle,
#            Zero and -ve, values can be used, relative to the clip width and height.
#            The defaults (0) sets ClipW to Width and ClipH to Height.
#         In Normal usage, (no borders/letterboxing), not used at all.
#         Sometimes (black borders) rarely more than 1 of these Clip? args
#         and never more than 2 will be set.
#         ClipX and ClipW should be in even numbers only (YUY2).
#
#     float spow, 1.0 to 150.0, Default 2.2
#         When mixing blurred horizontal and vertical bars either side, top and bottom,
#         of a logo, this arg controls the mix. When spow==1.0, the bars with the
#         longest sides are given precedence weighted by how long they are compared
#         to the other bars. If the vertical bars either side of the logo are eg
#         100 pixels tall and the horizontal bars are 50, then the vertical bars
#         are mixed with 2:1 the strength of the horizontal bars, ie 66%, (about
#         170 for argument to Layer(), 256*0.66). Dekafka would have given this
#         example a strength of 255, close to 100% (255/256). Strangely, if lengths
#         were swapped about, it would have gotten a strength of 64, = 25%. s_ExLogo
#         is symetrical, whereas Dekafka is not.
#
#         Based on the above example where vertical bars are twice as long as the
#         horizontal bars:-
#         spow        V_Strength%     Layer_arg          ratio
#         1.0            66%            170               2:1      (Linear)
#         1.6            75%            191               3:1
#         2.2            80%            205               4:1      (Default)
#         2.8            83%            213               5:1
#         3.3            86%            219               6:1
#         4.0            88%            224               7:1
#         4.6            89%            228               8:1
#         5.0            90%            230               9:1
#         5.7            91%            233               10:1
#         143.0          99.6           255               255:1
#
#
#         As you can see, the above spow Default is 2.2, with a ratio of 4:1
#         meaning that if the vertical bars are twice as long as the horizontal ones,
#         they acquire a strength of 80%, 4:1 as opposed to 2:1 when linear spow of 1.0
#         is used.
#         Using spow=143.0 (or anywhere close) pretty much switches OFF the shortest side
#         which may have application. Anything else above about 5.7 is unlikely to be of
#         any great use. The spow arg does NOT produce miracles, but is something else
#         to play with if you get bored.
#           In this version, the default spow has reverted back to the original test value
#         of 2.2 (was 1.6 in first release). spow really is just an externally adjustable
#         default value, meant for testing and not really intended to be changed, suggest
#         that if you dont like the default setting, that you manually change it in the
#         source instead of submitting an spow arg every time its used.
#
#     int Mix, -1 to 256, default -1 (Use SPow)
#         Overrides Spow calculations for controlling mixing of vertical and horizontal
#         bars based on vertical : horizontal ratio.
#         Sets the argument passed to 'Layer()" directly, eg 256 uses ALL of the vertical
#         bars and NONE of the horizontal, 128 does a 50/50 mix and 0 uses only
#         horizontal bars. For one-off adjustments, may be best to use Mix instead
#         of using the spow arg.
#
#     int Amount, 0-256, Default 252, How much of blurred de-logo is used.
#         This controls  how much of the blurred de-logo put together by spow (or Mix, above)
#         is finally combined with the original clip to replace the logo area.
#
#------------------------------------------------------------------------ 
#  X-Coords should be in even numbers only (YUY2).
# -------
#  IN-USE:
#    Position logo using LogoMode=0 (Ignores clipping in this mode).
#      Displays Logo area as a "dimmed" rectangle. MUST SET LOGO IN THIS MODE 1st.
#    If borders/letterboxing, then:
#      Switch to LogoMode=1,
#         Shows Patch (CLIPPED logo) position & Clipping. NON CLIPPED area shown in GREEN.
#         NOTE, the Logo rectangle (patch) will have been clipped in this mode and any
#         that has been clipped out will NOT be hi-lited. Changed NON Clipped color
#         in v1.1 from Pink to GREEN. I'm sure that a better (more intuitive) method for
#         clipped hi-liting could be found, but this is the easy way, and I'm basically lazy.
#    When coords of Logo and optional clipping set then:
#      Switch to LogoMode=2, Normal usage. (LogoMode 3 and 4, may also have application)
# -------
#  CLIPPING:
#    If you have a standard set of LOGO coords for a particular station logo then
#    you would use these LOGO coords whether or not there are any borders/letterboxing.
#    You would only use the CLIP coords if borders/letterboxing, LOGO coords are NOT
#    changed. The only Clipping coords that need be set, are the ones where the
#    borders are, so if eg:
#      Video clip has eg letter boxing top and bottom, and logo is in top left, then:
#        Use LogoMode=1, to set only "ClipY", in this case ClipY should be the coord
#        of the topmost logo pixel that does NOT contain any border.
#        When set correctly, switch to LogoMode=2 (default use).
#        Blurred de-logo data is (in this case) taken only from left, right and bottom
#        of logo patch area. (Patch area = clipped LOGO area). 
# -------
#  SOME USAGE EXAMPLES, TO SHOW YOU WHAT TO EXPECT with LogoModes 0 and 1.
#
#  s_ExLogo(20,20,100,100,LogoMode=0)			# Logo Top LHS, No clipping, Show Logo 
#  s_ExLogo(20,20,100,100,ClipY=70,LogoMode=1)  # Logo Top LHS, Top HALF LOGO Clipped, Show Logo/Clipping 
#
#  s_ExLogo(0,12,-0,40,LogoMode=0)			    # Full width scrolling logo, No clipping, Show Logo 
#  s_ExLogo(0,12,-0,40,ClipY=32,logomode=1)	    # Full width scrolling logo, Top HALF LOGO Clipped, Show Logo/Clipping
# -------
#  LASTLY, Have had pretty impressive results using this as a post processor to AvsInpaint with low setting
#  for amount and FFT3DFilter doing a further little bit of smoothing on a cropped area slightly larger
#  than the patch area. (AvsInpaint using InPaintFunc.avs by Reuf Toc). AvsInpaint, can be a little on the slow
#  side, but whilst you are waiting, you could always spend your time wisely, perhaps; write a good book.
#------------------------------------------------------------------------
Find v1.1 s_ExLogo update here:

Also, if comments/complaints, post here.

Please Enjoy

Last edited by StainlessS; 16th June 2011 at 03:58. Reason: Spelt FFT3DFilter as FF3DFilter
StainlessS is offline   Reply With Quote
 

Tags
dekafka, delogo, logo, logo removal

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 03:32.


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