Log in

View Full Version : InpaintDelogo - advanced logo removal & hardcoded subtitles extraction


Pages : [1] 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

VoodooFX
31st August 2019, 21:57
##================================================================================================##
# #
# ____ _ __ ____ __ #
# / _/___ ____ ____ _(_)___ / /_/ __ \___ / /___ ____ ____ #
# / // __ \/ __ \/ __ `/ / __ \/ __/ / / / _ \/ / __ \/ __ `/ __ \ #
# _/ // / / / /_/ / /_/ / / / / / /_/ /_/ / __/ / /_/ / /_/ / /_/ / #
# /___/_/ /_/ .___/\__,_/_/_/ /_/\__/_____/\___/_/\____/\__, /\____/ #
# /_/ /____/ #
# #
##================================================================================================##


# InpaintDelogo is an advanced logo and watermark removal function using inpainting and deblending
# with an adjustable fine process to hide artifacts and get best delogo results.
# Can remove opaque, transparent, semi-transparent and some dynamic logos from video.
# Can be used to remove hardcoded subtitles or extract them to images for OCR.

# Inpainting refers to the application of sophisticated algorithms to reconstruct of lost
# or deteriorated parts of images or videos.


##================================================================================================##

Someone asked for my delogo script, so here it is: InpaintDelogo() is user friendly script for AvsInpaint plugin (plugin created by Wolfgang Boiger).
Why another script for AvsInpaint!? Because other scripts - rm_logo & InpaintFunc are both semi-broken, slow inpainting, with subpar to unusable results.

AvsInpaint is a great plugin, questionably the best tool atm to remove logos. With InpaintDelogo you can expect better delogo results than from any other tool.
InpaintDelogo can save your time by generating a logo mask automatically, get Color/Alpha masks for deblending in a second, 3x times faster inpainting than with previous user friendly scripts.

Issues with previous scripts for AvsInpaint:

InpaintFunc Deblend: Results from poor to unusable. As in practice you can't get good masks by analyzing random frames.
InpaintFunc Both: Broken. Results same as Inpaint, simply there is no code to do it.
InpaintFunc Inpaint: Works. No controls. Very slow.
InpaintFunc PP: Subpar. Broken code creates edges and PP=3 can't solve it.

rm_logo Deblend: Results from poor to unusable. Same as InpaintFunc.
rm_logo Both: Broken. Does both but can't do PP as there is no masks to do it.
rm_logo Inpaint: Works. Very slow.
rm_logo PP: Works (not for both).


Benchmarks (in brackets - fps with all new features On. rm_logo is modded for speed or it wouldn't be able to run test at all, both rm_logo & InpaintFunc runs at ~same speed. ):

InpaintDelogo v1.11 rm_logo v0.6_mod/InpaintFunc v1.15
180x180(pre cut):
Deblend 702 fps (153 fps) 587 Fps
Inpaint 33 fps 10 fps
Both 47 fps 10 fps

1920x1080:
Deblend 121 fps (60 fps) 121 Fps
Inpaint 12 fps 4 fps



Basic short guide( things you need before doing delogo ):
0) Read help/manual (at the top of the script) about parameters mentioned below.
1) Run this function to get "Loc" values: InpaintLoc(Loc="100,100,-100,-100"). Adjust "Loc" crop parameters around logo (aka "Left,Top,-Right,-Bottom"). Use even(mod2) numbers.
2) Prepare the "mask" manually, or start InpaintDelogo with "Automask=1" and "Analyze=2", automask result can be adjusted with"aMix".

Some basic delogo parameters for non-transparent logo:

InpaintDelogo( mask="D:\mask.bmp", Automask=0, aMix=0, Loc="100,100,-100,-100", Mode="Inpaint")



Version history:

# Version 3.7 : 2023/08/11. Fixed: Broken "YColorSolidIns" arg [code typo].
# Fixed: Bug with "isHD" variable.
# Added 'Mask' path check before running 'Automask'.
# New params: "UVAlphaFromY", "SubPrefix", "SubPostfix".
# Removed "colors_rgb.avsi" dependancy.
# Changed "mShow" to red instead of black.
# Version 3.6 : 2023/01/12. New conditional: Auto max "Interp" for frames where logo is in ~solid background.
# "Optimize" is split to "Optimize1" & "Optimize2".
# Burnin version number into ebmp ["Ver-", positive analyze only].
# Version 3.5 : 2022/12/27. Fixed: Dynamic mask inpainting was broken since v3.4.
# Version 3.4 : 2022/11/24. New feature: "Greyscale" parameter, affects positive "Analyze", "Deblend", "Inpaint"...
# Up to ~60% speed-up when enabled.
# Prevents chroma changes on the greyscale videos by deblend [side effect of "3.1" fix].
# FFT3DFilter replaced by Neo_FFT3D, up to ~20% speed-up.
# Version 3.3 : 2022/11/13. Corrected a code 'typo' in SubsMask2Img(), introduced in v2.10.
# Version 3.2 : 2022/10/22. New feature: Conditional optimizations with "Optimize", enabled by default.
# Up to ~1000% speed-up for slow "Inpaint" & "Interp" presets.
# Additional auto "Interp" disabling.
# New feature: Negative "dPP"/"oPP", adds denoise, enabled by default [20%-50% slow down].
# Very slow inpainting preset: Turbo=-2.
# Quick masks dump with clean "outs": DumpMasks=2.
# Various other tweaks.
# FFT3DFilter plugin is required.
# Version 3.1 : 2022/10/11. Fixed: "Deblend" with positive "Analyze" was unreliable on the colored logos.
# Version 3.00 : 2022/10/07. Fixed: A frame selection scan result wasn't saved properly when "Automask=1" and "Inpaint" mode,
# now the deblending masks generation is up to twice faster in this scenario.
# New feature: Easy use of the ebmp masks on other videos, you can input them directly with "Mask" parameter.
# Ebmp format is changed, the masks from older versions are not compatible.
# New feature: Twice faster subtitles extraction with auto intermediate file.
# It's activated by negative "Extract" values.
# Requirements: LSMASH, TWriteAVI, x264vfw.
# New params: "ReExtract", "FourCC".
# New feature: Adjustable subs detection window, useful if video has non-middle subs alignment.
# New params: "DetWinPercW", "DetWinPercH", "DetWinHoPos".
# With "Show=12" you can see the subs detection window and correlation coefficient [CorrTh/Corr].
# New: "Turbo=-1", it activates an inpainting preset more suitable for UHD - HD resolutions.
# New: "IntSpd=4", similar as above.
# Basemask change: Background should be less than full white, logo - full white.
# Swapped "Turbo" 1 & 3.
# Removed "rSize" parameter.
# Reworked "Show=2", alternative to "Show=1" for positive Analyze.
# New feature: Various parameters to manipulate the deblending masks from positive analyze [for the experts only]:
# "YAlphaTweak", "UAlphaTweak", "VAlphaTweak",
# "YAlphaSolidIns", "UAlphaSolidIns", "VAlphaSolidIns",
# "YAlphaSolidOuts", "UAlphaSolidOuts", "VAlphaSolidOuts",
# "YColorSolid", "UColorSolid", "VColorSolid",
# "YColorSolidOuts", "UColorSolidOuts", "VColorSolidOuts",
# "YColorSolidIns", "UColorSolidIns", "VColorSolidIns",
# "YOffsetIns", "YOffsetOuts", "UVOffsetIns", "UVOffsetOuts", "ShiftMasksVe", "ShiftMasksHo",
# "YAlphaExternal", "WholeDeblend", "TriggerDynamic", "DumpMasks".
# Various other tweaks.
# Avisynth+ v3.7.2 or later is required.
#
#---------------------------------------------------------------------------------------------------
#
# Version 2.17 : 2022/06/13. Option for ranged luma mask with DynMask6.
# Version 2.16 : 2022/06/12. Higher quality and faster "DynColor" mask when used with "DynLocUp".
# Faster "DynColor" alternative if parameter is string, and it supports multiple colors.
# TColorMask plugin is required.
# Version 2.15 : 2022/05/29. Spaces are allowed in "Loc".
# Version 2.14 : 2022/05/22. SubsMask2Img: New option to extract raw non-binarized images.
# Enabled by "Extract=2" in InpaintDelogo() or "Raw" in SubsMask2Img().
# New: "Raw", "RawAvr".
# Version 2.13 : 2022/05/21. SubsMask2Img: Added average luma check to catch non-sub images.
# New: "SubMinLuma", "SubSusLuma".
# Renamed: "SubSuspect" to "SubSusDur".
# Version 2.12 : 2022/05/14. Added generation of the dynamic mask by gradient magnitude map (aka "DynMask=7"/"DynTEdge").
# New: "DynTEdge", "DynTEdgeThY", "DynTEdgeInf", "DynTuneInf", Show=10, Show=11.
# vsTEdgeMask plugin is required.
# Version 2.11 : 2022/05/13. Rewrite: "DynColor" ~30%-300% faster. New: "DynMask=6/"DynTune". Removed: "Show=10".
# Version 2.10 : 2022/05/02. Added auto generation of the dynamic mask by color (aka "DynMask=5"/"DynColor").
# New: "DynColor", "DynColorTol", "DynColorInf", "Show=10".
# This dynamic mask by color can pre-patch video for other "DynMask" methods.
# Version 2.09 : 2022/04/08. Positive "DynMaskUp" is supported with "DynMask=3".
# Improved "KillNoise".
# Version 2.08 : 2022/04/07. Improved negative "KillBlobs".
# Version 2.07 : 2022/04/06. Changed defaults of the sub-parameters for "DynMask=3" (no need to set the bunch of parameters anymore).
# Version 2.06 : 2022/04/06. Fixed: "Show=3" was broken since v1.36.
# Version 2.05 : 2022/04/04. Masktools2 v2.2.30 or later is required.
# Tweaked: "DynMask=4" and positive "DynMaskUp", should be a bit faster and no more glitches.
# New: "DynLocUp" [Experimental WIP parameter for tests].
# Version 2.04 : 2022/02/11. Improved deblend quality with positive "Analyze" when frames quantity to analyze is low.
# Tweaked: A/C masks filename from negative "Analyze" ('Deep' goes to the end of the filename).
# Tweaked: "iTune", "EdgeWide".
# Version 2.03 : 2021/12/13. Tweaked "DynTune".
# Version 2.02 : 2021/12/10. Fixed: "Analyze=1" bug.
# +11% deblend speed-up.
# Tweaked "aMix". "Analyze=2" is default. Adaptive "AnalyzeTh" default [16 or 30].
# Don't search frames for analyse if 'txt' file is present and ReAnalyze=0.
# Version 2.01 : 2021/12/05. "Analyze" 3 option.
# Version 2.00 : 2021/12/04. AviSynth+ v3.7.1 or later & FrameSel plugin is required.
# New: Old Deblend delogo is superceded by the new superior one.
# New: Smart frames selection for analyze using "AnalyzeTh" & "NoBorderAt" parameters.
# New: "Automask" adapted to the new stuff and it doesn't reanalyze when "aMix" is adjusted.
# New: "Show" 7/8/9.
# Note: Old Deblend is saved as negative "Analyze",
# -3/-4 should be same as old, -1/-2 were augmented by the smart frames selection.
#


Requirements:

# Core requirements:
# AviSynth+ v3.7.2 or later ( https://github.com/AviSynth/AviSynthPlus ).
# AvsInpaint v1.3 or later ( https://github.com/pinterf/AvsInpaint ).

# Other requirements:
# MaskTools2 ( https://github.com/pinterf/masktools ).
# RgTools ( https://github.com/pinterf/RgTools ).
# GRunT ( https://github.com/pinterf/GRunT ).
# RequestLinear ( https://github.com/pinterf/TIVTC ).
# ClipBlend ( http://avisynth.nl/index.php/ClipBlend ).
# RT_Stats ( http://avisynth.nl/index.php/RT_Stats ).
# FrameSel ( http://avisynth.nl/index.php/FrameSel ).
# GrainFactory3 ( http://avisynth.nl/index.php/GrainFactory3 ).
# vsTEdgeMask ( https://github.com/Asd-g/AviSynth-vsTEdgeMask ).
# TColorMask ( https://github.com/Asd-g/AviSynth-tcolormask ).


# Requirements for fast subtitles extraction:
# LSMASH ( http://avisynth.nl/index.php/LSMASHSource ).
# TWriteAVI ( https://github.com/Asd-g/AviSynth-TWriteAVI ).
# x264vfw ( https://sourceforge.net/projects/mpxplay/files/x264vfw ).


Notes for AviSynth v2.6 users:

# Last compatible version is 1.48
# Requirement: GScript ( http://avisynth.nl/index.php/GScript ).
# "InpaintDelogo.avsi" needs to be renamed to "InpaintDelogo.avs",
# and loaded manually in AviSynth script with: GImport("C:\AviSynth 2.5\plugins\InpaintDelogo.avs"),
# or use AvsInit for autoloading ( https://forum.doom9.org/showthread.php?t=176749 ).
# Subs extraction is up to 600% slower than with AviSynth+!


Helper scripts:
A script that can extract forced cues from a full subtitle: https://github.com/pcroland/substoforced
Automatic switching between alternating logos: https://forum.doom9.org/showthread.php?t=186921


Download link:
Latest version v3.7: https://github.com/Purfview/InpaintDelogo

VoodooFX
1st September 2019, 13:19
Comparisons with rm_logo and InpaintFunc:

Easy logo to deblend:
Original (zoomed in few times):
https://images2.imgbox.com/b1/54/t3qx5ZGs_o.png

Deblended: (1-InpaintDelogo, 2-InpaintFunc, 3-rm-delogo)
https://images2.imgbox.com/10/43/GC3AjRpB_o.png
https://images2.imgbox.com/8a/10/SAZtkOmw_o.png
https://images2.imgbox.com/36/f9/GqlAbiNp_o.png

Inpainted: (1-InpaintDelogo, 2-InpaintFunc, 3-rm-delogo)
https://images2.imgbox.com/c8/bf/Sk40SDKS_o.png
https://images2.imgbox.com/7c/a0/ve6Vng9e_o.png
https://images2.imgbox.com/67/14/EJXfzarE_o.png


Both logo:
1-Original, 2-InpaintDelogo, 3-rm_logo:
https://images2.imgbox.com/85/48/6jtR55VB_o.png
https://images2.imgbox.com/de/29/sEaKlxdV_o.png
https://images2.imgbox.com/93/ac/ZHMTsV14_o.png


Hard logo to deblend:
Deblended:
1-Original, 2-InpaintDelogo, 3-rm_logo/InpaintFunc(they look similar):
https://images2.imgbox.com/46/5c/1vdzaFIt_o.png
https://images2.imgbox.com/2e/53/tROrZREl_o.png
https://images2.imgbox.com/06/fd/vRzas4zP_o.png

johnmeyer
1st September 2019, 15:43
Interesting work. Thanks for doing that.

I've spent a lot of time using Delogo inside of Virtualdub, and even created a YouTube tutorial for it:

Tutorial on Delogo (https://www.youtube.com/watch?v=Z12TutFSg8c)

I did that tutorial in response to a long thread about how to eliminate a sensor defect from a camera. This is a considerably easier job than logo/bug removal and one that Delogo was able to do with near-perfection.

I have not used any AVISynth logo removal tools, but I have used all the features of Delogo, including training it for removal of semi-transparent bugs, and specifying frame ranges for TV shows where the logo comes and goes, or moves around.

For me, the biggest need in advancing the state of the art is the blending algorithm. When the background is uniform and dark, such as the edges of a stage performance where the talent is brightly lit, but the wings of the stage are dark, the removal can be perfect. However, if the video was shot outdoors in the daylight, and the camera pans, you can get some pretty annoying results. For some videos, I just give up and leave it as is because the artifacts from the removal are worse than looking at the bug.

The problem is that the inpainting is nothing more than a blur function.

I know nothing about the technology of the existing AVISynth DLL you are using because I haven't used it, but the example above of the "Hawe Knho" shows the Inpaint blending looking pretty similar to Delogo. This is not meant as a criticism, but instead as a way to lead to my main question:

Is there a reason why I would want to use this instead of continuing to use Delogo? What are its advantages?

I am always looking for something that works either better or faster. Delogo is plenty fast, and it is also easy to use because it lets me tune the mask parameter interactively using the VD "preview" display. I want something that can make the logo disappear, with almost no residual evidence that it was there.

Is this possible?

I think it might be. If I were going to do development in this area, I'd look at how RemoveDirt does its painting. I just did a restoration of one of the most spectacularly degraded movies I've ever dealt with, a one-of-a-kind 16mm print of a 1963 AFL football game. It had been badly stored, and the emulsion stuck to the backing on the adjacent film in the reel, so once every revolution of the big film reel, there were huge (1/3 of the frame) chunks of mottled image. Where the emulsion had been completely removed, and there was no image, I had to reconstruct by hand from adjacent frames. However, when it was just a big stain, I used a heavily modified version of RemoveDirtMC to fix it, and when it worked, the reconstructed frame was near-perfect.

I haven't posted the results of this work, because it is copyrighted, but I did post a very short before/after of some Polavision restoration. This instant movie film from Polaroid had much of the same problem, because the film was developed in the cassette and then stayed there for 40+ years and, because of the residual chemicals, stuck together and, when unwound after all those years, the emulsion would come off, resulting in a black spot on one frame, and a matching blank spot a few frames later. Here is a few "before/after" frames from that work. You'll need to freeze at a random frame to see the results of what RemoveDirt was able to do. I did no manual work at all; it was all done by RemoveDirt.

Before After Polavision (https://www.youtube.com/watch?v=gzTistk2Ms0)

Whatever inpainting algorithms RemoveDirt uses might provide some ideas for how to do better logo removal.

StainlessS
1st September 2019, 18:00
I think that you will find that RemoveDirt uses temporal info from adjacent frames to fix spots/dirt, logo is entirely different being also on adjacent frames.

Looks nice VDX.

johnmeyer
1st September 2019, 19:19
I think that you will find that RemoveDirt uses temporal info from adjacent frames to fix spots/dirt, logo is entirely different being also on adjacent frames.Thanks, StainlessS. I wondered to myself as I was writing that last post whether that might be the case and, if that is the secret, you are right: it would be mostly useless for logo removal.

Having said that, in theory (maybe not in practice) you could use motion estimation from adjacent frames to predict what should be under the logo in the current frame and come up with a better replacement. It might work for my example of what happens when the camera pans. However, in practice, it probably wouldn't be useful, and would be of no help at all unless there was motion going through/under the logo.

P.S. The other area for improvement would be semi-transparent logos. In that case you DO have information on what is behind the logo. My experience, even with Delogo, is that if the logo is really faint, so you can see lots of detail behind it, you can get remarkably good, artifact-free removal.

VoodooFX
1st September 2019, 23:55
Is there a reason why I would want to use this instead of continuing to use Delogo? What are its advantages?
I am always looking for something that works either better or faster.

Delogo is pretty outdated, there were tools that perform way better, and InpaintDelogo does better than those other ones. Let me know if you find tool/script doing better job than InpaintDelogo. :cool:

The problem is that the inpainting is nothing more than a blur function.
You are mixing up something, it's not a "blur" function or a temporal thing like RemoveDirt.
Here is good starting point to read about it - Inpainting (https://en.wikipedia.org/wiki/Inpainting)

Having said that, in theory (maybe not in practice) you could use motion estimation from adjacent frames to predict what should be under the logo in the current frame...
It sounds good only in theory, in practice it would be very complicated task to implement something to fit various cases of motion, actually it was implemented and was called "msu" something.

StainlessS
2nd September 2019, 02:13
John, the S_Exlogo() thing I did [ based on DeKafka() ], is purely blurring the logo [using data from spatially outside of the logo], but not the AvsInpaint.dll based scripts [as is this one],
however, S_Exlogo() is easy to set up and goes like the clappers, and so long as you are easily pleased, is quite good [a man on a galloping horse might not notice any remaining logo].

MC based delogo [as with mvtools] is doomed to failure, methinks.
[neural network stuff might at some future date be much better than today, but would likely be a somewhat unstable [although maybe less so if 3D neural networks],
ExInpaint [another dll] uses something along those lines [purely spatial, I think] and is a little temporally unstable but good for single frames (see the demo image in docs)]

EDIT: Think ExInpaint is using the "Exemplar-based image inpainting" in above link, seem to remember the word 'Exemplar' being used in the docs [and source for the plugin name].

from above VDX link
Exemplar-based image inpainting attempts to automate the clone tool process. It fills "holes" in the image by searching for similar patches in a nearby source
region of the image, and copying the pixels from the most similar patch into the hole. By performing the fill at the patch level as opposed to the pixel level, the
algorithm reduces blurring artifacts caused by prior techniques.

EDIT:
it was implemented and was called "msu" something.
MSU Subtitle and Logo Remover:- http://forum.doom9.org/showthread.php?t=95955
Use this
global VDub = "C:\Programme\AviSynth 2.5\VDub\plugins"

LoadVirtualdubPlugin(VDub+"\MSU_DeLogo.vdf", "_MSUDeLogo")


The open VirtualDub. Add to the filters the MSUDelogo-Filter. Tweak it, so it remove your Logo fine. Go to
FILE ->
SAVE PROCESSING SETTINGS...

and save them to a file. Open The file in a texteditor and look for line like this one:
VirtualDub.video.filters.Add("MSU Subtitle&Logo Remover");
VirtualDub.video.filters.instance[0].Config(0, 0);


Now copy allparameters in Config and use the to Call the Filter in Avisynth this way:
ConvertToRGB32._MSUDeLogo(0, 0)

I tried the filter but does not get good results with it. It is also very slow. Have you better results with this filter?

Many MSU Vdub filters do NOT export some of the settings, [described in code above as Config] and so cannot be used properley in Avisynth, [settings only exist when set up within VDub, and
cannot be saved and reused at a later date, even within VDub], dont know if MSU_Delogo is one of those which do not save ALL settings.

EDIT: Dont know/recall what method AvsInpaint dll is using [the one used by this script].

VoodooFX
3rd September 2019, 17:34
the S_Exlogo() thing I did [ based on DeKafka() ], is purely blurring the logo...

I was thinking to add Very Fast mode where s_Exlogo could do post-processing, could be useful for big logos where there is no point to use slow inpainting. But forgot about it as I didn't wrote that to todo list :) .
I strikethrough that list today, only one line left - "moving logo", it should be doable in theory but could be over my head, maybe I'll replace it with "very fast mode". :D

MSU Subtitle and Logo Remover...

I looked at MSU site, it is called MSU Logo Remover 2.xx, MC implementation is broken, no open source...

Dont know/recall what method AvsInpaint dll is using [the one used by this script].

Ideas are implemented from these papers:

Folkmar Bornemann, Tom März: Fast Image Inpainting Based on Coherence Transport.
Joachim Weickert: Coherence-Enhancing Shock Filters.
Alexandru Telea: An Image Inpainting Technique Based on the Fast Marching Method.
James Sethian: Fast Marching Methods.

StainlessS
3rd September 2019, 18:07
I should go back to my current mod for s_Exlogo(), It stalled a bit when I bumped into a bug in r2772, fixed now in bugfix avs+ test build (r2915), but been a bit busy of late.

I've seen some delogo stuff that was somewhat like s_ExLogo(), but seems to take most data from mostly one side (inner most long side), but partially mixed with other sides,
it in some cases was way better than s_ExLogo, I could not figure out how it worked. [sending you a link, not suitable clip for general viewing].

VoodooFX
4th September 2019, 22:56
I've seen some delogo stuff that was somewhat like s_ExLogo(), but seems to take most data from mostly one side (inner most long side), but partially mixed with other sides,
it in some cases was way better than s_ExLogo, I could not figure out how it worked. [sending you a link, not suitable clip for general viewing].

That looks pretty simple, take 2 pixels at the top resize them to the size of the hole. I don't see any interpolation from other sides.

StainlessS
4th September 2019, 23:47
Oh, simple as that, I guess I was seeing stuff that wern't there.
Thanks awfully :)

EDIT: sometimes less is more.

VoodooFX
5th September 2019, 00:29
I just tested it to be sure. Sometimes in original I see some discrepancies, but I don't have any logical explanation, maybe some compression/resize artifacts maybe broken delogo code. Like this one:

2x Size
1) original (SD), arrows to some artifacts, they appear and disappear without any apparent reason, but mostly it looks same as "3".
2) s_exLogo, delogo of "original", sides and bottom is blocked from interpolation, 4px left at top, "Amount=256".
3) 2px from the top resized. :)

https://images2.imgbox.com/d1/ff/dzI1b30l_o.png

manolito
5th September 2019, 01:07
You guys made me curious so I did some tests comparing s_ExLogo to the old LogoAway plugin by Krzysztof Wojdon. I did not test InpaintDelogo for several reasons (too complicated, I hate plugins with dozens of params, have to select frames and create masks manually, requires AVS+, no option for logos over black borders). Here are the results:
https://www.sendspace.com/file/8nvhi6

For s_ExLogo I used the default parameters, for LogoAway the UGLARM method was used with the blur slider set to max (all the way to the right).

https://i.postimg.cc/9fFcJcFF/LogoAway.png (https://postimages.org/)

LogoAway also has a much faster XYBlur mode which creates results very similar to s_ExLogo. But UGLARM does look so much better in almost every situation that I have been using this mode exclusively over the last couple of years.

Now I would like to challenge VooDooFX if his script can create a better looking result. My requirements are pretty simple:

1. Just 1 mode for opaque logos. I do not care for semi-transparent logos.
2. No manual mask creation. All I want to provide to the plugin are the logo coordinates.
3. I do not mind if the logo area gets blurred strongly. All I want is that my attention is not taken away from the movie itself, so the delogo'd area should be as unobtrusive as possible, mainly I hate when this area shows strong flickering.
4. Easy to use and reasonably fast.

Tough challenge, I know. For now I will stick with LogoAway, s_ExLogo is no serious contender IMO.


Cheers
manolito

StainlessS
5th September 2019, 14:22
Mani, for s_ExLogo, sPow=1.0 (linear) should be about same as your XYBlur mode [I think].

VoodooFX
5th September 2019, 20:26
Now I would like to challenge VooDooFX...

Do you want some fast preset? I'll look what can be done. Can you PM link to that unresized logo?

manolito
5th September 2019, 20:46
Do you want some fast preset? I'll look what can be done. Can you PM link to that unresized logo?
Of course faster is better, if the result does not suffer too much.

For the "unresized logo" I don't know what you mean. The original source is a German DVB-T2 capture which means 1080p @ 50fps. Applying logo removal at this resolution is forbiddingly slow, and since my target format is SD (704 x 396) I perform my logo removal after resizing which is way faster.

So you need to use the "Source.mkv" file in my upload as your source for the logo removal.

VoodooFX
5th September 2019, 21:07
It's just for personal tests, logo is "both" and I don't have much logos to test that mode on. If you have source then I would be happy with just the logo cut with surrounding of ~80 px (no need black bar), ~5-10 mins, ~Lagarith YV12, should include frame where logo is in a black background.

VoodooFX
6th September 2019, 23:41
New version 1.12 attached at original post.
Various tweaks for speed and quality. Changed "Inflate", "Deep" now is not re-analyzed on every load, selectable number of passes for "Deep".
New "Turbo" presets parameter for fast and blurry logo removal, few other parameters.

v1.12 Deblend, 2x zoom:
https://images2.imgbox.com/e8/c5/y4Y0IVHq_o.png

v1.11 Deblend, 2x zoom:
https://images2.imgbox.com/c1/85/d518TgUm_o.png




You guys made me curious so I did some tests comparing s_ExLogo to the old LogoAway plugin by Krzysztof Wojdon. I did not test InpaintDelogo for several reasons (too complicated, I hate plugins with dozens of params, have to select frames and create masks manually, requires AVS+, no option for logos over black borders). Here are the results:
https://www.sendspace.com/file/8nvhi6

For s_ExLogo I used the default parameters, for LogoAway the UGLARM method was used with the blur slider set to max (all the way to the right).



LogoAway also has a much faster XYBlur mode which creates results very similar to s_ExLogo. But UGLARM does look so much better in almost every situation that I have been using this mode exclusively over the last couple of years.

Now I would like to challenge VooDooFX if his script can create a better looking result. My requirements are pretty simple:

1. Just 1 mode for opaque logos. I do not care for semi-transparent logos.
2. No manual mask creation. All I want to provide to the plugin are the logo coordinates.
3. I do not mind if the logo area gets blurred strongly. All I want is that my attention is not taken away from the movie itself, so the delogo'd area should be as unobtrusive as possible, mainly I hate when this area shows strong flickering.
4. Easy to use and reasonably fast.

Tough challenge, I know. For now I will stick with LogoAway, s_ExLogo is no serious contender IMO.


Cheers
manolito

a) "too complicated" - It's relatively simple.
b) "dozens of params" - It's not mandatory to use them all, you can use only 2 parameters if you want. LogoAway has dozens parameters too...
c) "have to select frames and create masks manually" - Not mandatory. Quote from op - "can save your time by generating a logo mask automatically".
d) "requires AVS+" - Not mandatory.
e) "no option for logos over black borders" - Does it prevent you to delogo? You said it has too many params already. :)

1) There is already such mode.
2) Mask generation is automatic already.
3) You can do that already. Why you don't want to use deblend? It would remove your logo almost without a trace.
4) It is easy already. Added new fast "Turbo" presets parameter in v1.12.

https://thumbs2.imgbox.com/8c/8c/LA1EL2fB_t.png (https://i.postimg.cc/9fFcJcFF/LogoAway.png[/url)

Whole comparison video: [url]https://we.tl/t-kcAI66C8GQ

manolito
7th September 2019, 02:08
Thanks for these comparisons... :)

Especially the "Turbo=1" mode impresses me. In most cases it looks just as good or even better than the slower "Turbo=3" mode. This mode is something I would really be interested in...

The speed comparison with LogoAway is a little unfair. I use an "Active Area" approach where VDub just processes the actual logo. It was inspired by Didées DeLogo script, but a little bit expanded and added exception handling with the help of gavino. Makes it much faster.

Your new version is not approved yet by a mod, please upload it somewhere else.

For the AVS+ requirement this is what you say in the first post of this thread:
Requirement:
Avisynth+ r2915 or newer ( https://github.com/pinterf/AviSynthPlus )
Please tell me what I have to change under classic AVS 2.60.

And then I would like to know how you can preview your results. For LogoAway it is easy: In VDub you can visually see the different results when you change any of the parameters. In AviSynth would I have to use AVSP(mod) to interactively see the results when changing parameters?

And for treating logos which are partly over letterboxed (or pillarboxed) areas do you have any special treatment for such logos? LogoAway and s_ExLogo do have provisions for such logos.

manono
7th September 2019, 03:13
Your new version is not approved yet by a mod...

I'll do it immediately.

Please tell me what I have to change under classic AVS 2.60.

Me too. I have no interest in AviSynth+ yet and do a lot of logo removal using InPaintFunc.

VoodooFX
7th September 2019, 03:41
Especially the "Turbo=1" mode impresses me. In most cases it looks just as good or even better than the slower "Turbo=3" mode. This mode is something I would really be interested in...


I think you are concentrating on some frames too much, in general Turbo=3 is less alive.
Turbo=1 is using bit lower oPP=6 (opaque blur) as it gets more blur than 1/2 by other means, when Turbo=3/Turbo=2 is using oPP=7, you can change options to whatever you want, like to oPP=8 (max amount of unhealthy blur). Turbo are not hard presets.

Avs+ is my recommendation, it is faster maybe ~10%, script works with Avs 2.6 too without any changes.


The speed comparison with LogoAway is a little unfair. I use an "Active Area" approach where VDub just processes the actual logo.

LogoAway benchmark didn't go through conversion to YV12, so it's unfair for others. :) I benchmarked that small pre-cut area , it would be close to "Active Area".


And for treating logos which are partly over letterboxed (or pillarboxed) areas do you have any special treatment for such logos?
Just don't select that border with Loc (I didn't tested such case).


And then I would like to know how you can preview...
I use Notepad or other txt editor like PSPad, I never had any need for something fancy like AvsMod, I just need preview, and I get it from programs I already have installed.
You can open your avs script with same Vdub, change something in your script>save then in VDub>File>Reopen and it will refresh preview at same frame you are looking at.

VirtualDub2 has its own avs script editor and F5 will do as above.

Then MeGUI has script editor and preview, I like it most as preview window is not bonded to main program.

johnmeyer
7th September 2019, 04:53
That's a great comparison video.

I wonder if s_Exlogo's settings were correct. As I indicated earlier, I've done a lot of logo removal using Delogo, and you can set it so its "inpainting" is done primarily from pixels above and below the logo, which is what I see in the s_Exlogo example.

Your function does a good job, but it does look similar to what I get with Delogo. If you have a version of the original, I'd be happy to create a demo of what can be done with that, and see how it compares to yours.

manolito
7th September 2019, 12:29
If you have a version of the original, I'd be happy to create a demo of what can be done with that, and see how it compares to yours.

The file "Source.mkv" from this link...
https://www.sendspace.com/file/8nvhi6

VoodooFX
7th September 2019, 14:43
That's a great comparison video.

I wonder if s_Exlogo's settings were correct. As I indicated earlier, I've done a lot of logo removal using Delogo, and you can set it so its "inpainting" is done primarily from pixels above and below the logo, which is what I see in the s_Exlogo example.

Your function does a good job, but it does look similar to what I get with Delogo. If you have a version of the original, I'd be happy to create a demo of what can be done with that, and see how it compares to yours.
That is how s_Exlogo looks. Blur looks similar to blur, I know what Delogo does, I can tell you from my memory:

You have to do mask manually.
It is slow.
Bit more solid "smoked glass" look.
Doesn't hide edges.

Advantages over LogoAway:
Interpolates from the edges of the mask, so doesn't damage good parts of the frame.
Probably faster.

Advantages over InpaintDelogo:
None.

StainlessS
7th September 2019, 15:40
By the way, it was mostly the likes of the angled vertical tan/brown edge on left below (top & bottom images) that threw me,
center one s_exlogo is vertical edge, others angled, (did not realize where the angle was coming from [is from 2 pixel resize]).
https://images2.imgbox.com/d1/ff/dzI1b30l_o.png

EDIT: Dekafka does a 2 pixel resize, but I did not like that and only use single pixel nearest to logo in resize (with opposite pixel from bottom edge),
seems that 2 pixel resize may be not so bad after all [but still seems weird to me, shifting two pixels and resizing].
The dark 'lip' at top of tan/brown edge #1(top) is likely due to the two pixel resize, and seems to have been cropped off for the bottom image #3.
[The lip is original image, the faded pixels below due to two pixel resize make it visually stand out]
EDIT: Also the top image seems to have 'more' angle than bottom image, something else seems to be going on there.
EDIT: And where is that brown line coming from [above to the left of left red arrow].

EDIT: Above requires no comment, just some observations.

VoodooFX
7th September 2019, 17:10
EDIT: Also the top image seems to have 'more' angle than bottom image, something else seems to be going on there.
EDIT: And where is that brown line coming from [above to the left of left red arrow].

a) We don't know history of that clip, delogo could be done on HD (interpolating ~4 top pixels), then clip resized to SD.

b) Do you mean that oblique line? It is above delogoed area, and it hits other vertical line just ~3-4px above delogoed area.

If you interested you can look at xLogo interpolation, it is fast and tries to make choices on vertical lines over horizontal (with multi passes), what ends up with very flickery interpolation.

manolito
7th September 2019, 19:35
I spent the better part of the afternoon testing InpaintDelogo, and in short the result is that I will abandon LogoAway and use InpaintDelogo instead... :D

As my source I used the same "Source.mkv" clip I uploaded (because it is very typical for my use cases). I used the Inpaint mode (part of the logo is semi-transparent, the other part is opaque), and I tried it without Turbo, Turbo=1 and Turbo=3. I also tested adding the "KillShape=1" parameter.

First of all I must say that the Automask feature works well. Just some small white spots which did not affect the results at all (I compared it to the results after manually cleaning up the mask).

For the different Turbo modes I could not point my fingers on any significant difference in visual quality. Even the result with Turbo OFF did not look noticeably better than Turbo Mode1. Of course this could be because my source was SD (or because my vision is degrading too much - getting old...).

These are the speeds I got:

LogoAway: 76.5 fps
Inpaint Turbo Off: 64.5 fps
Turbo=3: 88 fps
Turbo=1: 93 fps

Using "KillShape=1" with the Turbo modes slowed it down just a tiny bit, but the results did not look any better to me.

And all InpaintDelogo methods I tested looked way better than LogoAway, no doubt about it. So a big Thank You for your efforts... :thanks:

Some questions:
What about interlaced sources? Will they work out of the box? Or should I make the logo coefficients MOD4 instead of MOD2? And if GrainFactory functions are added, the GrainFactory doc says that it only supports progressive input.

I also tested a source where the logo is partly over the top letterbox. You said:
Just don't select that border with Loc (I didn't tested such case).
but this does not work. If I omit the top border value then the script will assume 0 as the value. Creating the AutoMask will fail with a "Mask Full" error message. The same thing happens when I set the top border value to the real top position of the logo.

The only way to get it working was to set the top value for the logo to the top of the movie area. This results in a clip where the logo part which lies over the top letterbox area will not be removed, this part needs to be cropped off after the logo removal. Pretty much the same procedure I have to use with LogoAway.


Cheers
manolito

VoodooFX
7th September 2019, 21:39
Those benchmarks doesn't look right as Turbo=1 is ~15x faster than Turbo=0, avs scripts should be benchmarked with AVSMeter. And I do it with uncompressed clip.
Or maybe you override Turbo presets by keeping other InpaintDelogo parameters in your script. Turbo just changes defaults. Like KillShape=1 is already in Turbo>=1 presets.
If you have mask generated then InpaintDelogo(mask="c:\mymask.bmp", Loc="0,0,-0,-0", Turbo=1) is enough for what you do (at least for that source clip you have shared), I use Show=2 to see only Loc area zoomed in.

Delogo needs to be done after deinterlacing, not before.

As with borders, in theory you need Loc at least 8 pixels from logo edges to generate good mask (Automask=1), you can use less but mask will be not that good, but as you just want to blur everything then it doesn't matter I guess.
When you done generating mask, then Loc will have different purpose, then you can set one of its edge to the back border without including it. If you have some problems with it then share that logo so I can look what is really going on.


First of all I must say that the Automask feature works well. Just some small white spots which did not affect the results at all (I compared it to the results after manually cleaning up the mask).

That bmp mask is just a base mask, inside InpaintDelogo it goes through various transformations, you can see them with Show=1 parameter.

StainlessS
8th September 2019, 00:04
b) Do you mean that oblique line? It is above delogoed area
Oops, yes of course.

manolito
8th September 2019, 20:34
Those benchmarks doesn't look right as Turbo=1 is ~15x faster than Turbo=0, avs scripts should be benchmarked with AVSMeter. And I do it with uncompressed clip.
Or maybe you override Turbo presets by keeping other InpaintDelogo parameters in your script. Turbo just changes defaults. Like KillShape=1 is already in Turbo>=1 presets.


Those benchmarks are totally right because they represent the real world conversion speeds. Just benchmarking the AVS script with AVSMeter does not tell you anything about the real world conversion speed where the bottle neck may be somewhere else (X264 in my case). So all my speed benchmarks are done in a "real" conversion scenario, not just using AVSMeter...


Some new findings while trying to establish a stable workflow for my SD conversions using InpaintDelogo:

For sources where the logo is partly in the black borders area your suggestion to just omit this border value after creating the mask does not work. An example for a logo which is partly in the top border area where the top movie border is at 52 pixels down from the top frame border:

For the logo location you need to set the top logo value to 52, then create the logo mask. This will keep the part of the logo which is in the black border area. To get rid of it you need to apply the command "Letterbox(52,0)" in the AVS script after the InpaintDelogo command.

I did some more tests with such a source (downloaded from the ARTE Mediathek, they usually place their logo partly in the black border area). I found the speed benchmarks very interesting:

Turbo=1: 80 fps
Turbo=3: 79 fps
Turbo=0: 71.5 fps

There is almost no difference between Turbo1 and Turbo3 mode, and even not using Turbo mode at all is only slightly slower. My conclusion is that I will probably ditch the Turbo modes completely. Of course this may be different for HD conversions, but I don't do those...

VoodooFX
9th September 2019, 15:16
Those benchmarks are totally right because they represent the real world conversion speeds. Just benchmarking the AVS script with AVSMeter does not tell you anything about the real world conversion speed where the bottle neck may be somewhere else (X264 in my case). So all my speed benchmarks are done in a "real" conversion scenario, not just using AVSMeter...

That way you are benchmarking Decoder+delogo+Encoder , that doesn't tell us much about delogo speed.
When we know real delogo speed then we can know how much Encoder's speed will be influenced by it.

Here is real delogo speeds (on i5-2450M 2.5GHz):
InpaintDelogo, Turbo=0 45 fps
InpaintDelogo, Turbo=3 304 fps
InpaintDelogo, Turbo=2 497 fps
InpaintDelogo, Turbo=1 736 fps

LogoAway, UGLARM, max Exponent, 61 fps
s_Ex_Logo 5288 fps



For sources where the logo is partly in the black borders area your suggestion to just omit this border value after creating the mask does not work.

I meant don't include black border in selection, not to omit setting the parameter.
I found such logo to test, it works as expected, like I wrote in a post above.

manolito
9th September 2019, 20:53
Alright, getting familiar with the InpaintDelogo method and really liking the results... :cool:

A feature request:
Is there a way to speed up the AutoMask creation?
I only use SD (704x396) clips as the input, but even then it takes almost 20 minutes to create the mask for a 2 and a half hour source clip. (Core i5 3rd generation CPU with 8GB of RAM, AVS+ with MT enabled using 4 threads.) The created mask is usually excellent, but there should be a way to make it faster, maybe by using only a percentage of the source. For a HD source clip of such a duration the AutoMask creation is useless for me, it takes more than an hour on my computer.

VoodooFX
9th September 2019, 22:22
I looked around how to remove moving logo, only solution I see is using Avisynthtrackin (https://sourceforge.net/projects/avisynthtrackin/), to automate everything would involve Python, I'm too lazy for that.


Is there a way to speed up the AutoMask creation?
I only use SD (704x396) clips as the input, but even then it takes almost 20 minutes to create the mask for a 2 and a half hour source clip. (Core i5 3rd generation CPU with 8GB of RAM, AVS+ with MT enabled using 4 threads.).

There is, instant analysis can be done with Analyze=4 or Analyze=3.
For "4" you need to enter frame number (for example Fr1=123) where logo is in a black/dark background. Frame numbers you can see in MeGUI or VirtualDub.
For "3" you need to enter black/dark and white/bright frames (Fr1 and Fr2).
If logo stays in that background longer than a second then you can add another parameter "FrS=3".

Default is Analyze=1 - ~3% of the clip, you can use Trim to limit it more.

Using MT will slow down encoding with InpaintDelogo, and will definitely slowdown Analyze part, if you are getting 20 mins with Prefetch(4) then removing it would speed Analyze up to 4 mins.
Try to measure encoding fps without MT. You are not using VirtualDub for that?

VoodooFX
9th September 2019, 23:53
Here is benchmarks AVS+ vs Classic AVS:

AVS+ 2915 AVS ST 2.6.0.6

InpaintDelogo, Turbo=0 45 fps 44 fps
InpaintDelogo, Turbo=3 304 fps 194 fps
InpaintDelogo, Turbo=2 497 fps 250 fps
InpaintDelogo, Turbo=1 736 fps 298 fps
s_Ex_Logo 5288 fps 3940 fps

manolito
10th September 2019, 01:29
Thanks for these benchmarks, but as I said before, they do not mean a thing to me. If the overall speed including decoding, AVS script plus encoding gives me an identical speed for Turbo=1 and Turbo=3, why in the world would I try to use the method which supposedly results in a lower quality? Makes no sense to me...

For the AutoMask feature when I want to get a better speed I was under the impression (from reading the doc) that I cannot use the "Analyze" parameter when I use the "Mode=Inpaint" parameter. And this is the only mode I ever use.

I tested it using "AutoMask=1" and "Analyze=1" and "Mode=Inpaint" in the command for creating the mask, and indeed the "Analyze=1" parameter was ignored. Creating the mask took just as long as without the "Analyze=1" parameter, and the resulting mask looked the same.

VoodooFX
10th September 2019, 02:06
Automask=1 is like separate function it only generates a base mask.

Only these parameters are used for Automask=1:
"Analyze" (and its sub-parameters, except "ReAnalyze"), "aMix", "mask" and "Loc" parameters will be used.

Mode is delogo parameter, it is silently ignored when Automask=1.

manolito
10th September 2019, 20:37
Still streamlining my workflow for InpaintDelogo, this time I used a typical real-world captured movie from German DVB-T2 (1080p @50fps, HEVC), duration was 100 minutes. I always convert these captures to 702x396 @25fps AVC. For InpaintDelogo I only use the Inpaint mode, I have no use for the Deblend or Both modes.

This is what I found so far:

Trying to use AutoMask to create the base mask was frustrating. It uses "Analyze=1" by default which means that it uses 3% of the source to create the mask. For my source file this is unusable, I canceled the process after 40 minutes. I got it working by increasing the "every" parameter in "SelectRangeEvery" from 33 to 400. Values above 400 caused the mask to deteriorate, but for this source 400 was perfect. It took 3 minutes to create a perfect mask. But of course this may be different for other source files.

The other and faster way is to use "Analyze=4" and specify a frame where the logo is above a perfect black background. I believe that for only using Inpaint it does not make sense to use "Analyze=3" because I will not do any color deblends.

Next problem was that my conversion crashed when I had activated MT mode. So far I have solved it by forcing InpaintLogo to MT_SERIALIZED, let's see if this helps permanently. Turning off MT mode is an option, but this drops my speed from 29fps to 25fps.

Still very happy with the resulting quality, even with Turbo=1 it is way way better than for LogoAway, and it is also faster.


Cheers
manolito

johnmeyer
10th September 2019, 20:44
I haven't yet tried InpaintDelogo, but for opaque masks is there any benefit to having it auto-create the mask? Or, is it able to track bugs which move? If so, that would be very useful. But, for static bugs, it only takes a few seconds to paint a mask, so there's no benefit in waiting minutes (or more) for the auto-creation.s

For semi-transparent bugs, auto-creation is mandatory, of course.

manolito
10th September 2019, 20:59
Just curious, but how do you make a BMP B/W mask at the required size and resolution in just a few seconds? I sure cannot do this, so using an AutoMask feature which only takes a few minutes doesn't sound too bad to me. And the other option when you can find a frame with the logo above a black background is lightning fast.

I always treat semi-transparent logos as if they were opaque, I'm too impatient I guess...

VoodooFX
10th September 2019, 22:29
If you know how to use PhotoShop then it is fast doing same thing as Automask=1: save dark frame, load it into PS then with Levels get mask, but if you already have black frame then there is no point wasting seconds/minutes with external programs when you will have same in milliseconds with Automask=1.

If it is only InpaintDelogo in a script then MT slows down encode. Very quick test, very slow x264 settings (1000 frames):

Only InpaintDelogo / Prefetch(4) - 12fps
Only InpaintDelogo / No MT - 16fps

InpaintDelogo + other 3 heavy filters / Prefetch(4) - 10fps
InpaintDelogo + other 3 heavy filters / No MT - 5fps

We can see that MT fps increase on other filters outweighs fps loss on InpaintDelogo here, or whatever MT does, I'm not an expert on that...
If it crash with Prefetch(4) then use 64bit. Or you can try Prefetch(3).

StainlessS
11th September 2019, 13:43
https://i.postimg.cc/9fFcJcFF/LogoAway.png (https://postimages.org/)


Mani, where did you get above info ?

Might try doing UGlarm thing, and add to s_ExLogo2()

EDIT: I presume that 'distance' is by Pythagoras.

manolito
11th September 2019, 14:24
It comes from here:
https://www.sendspace.com/file/odmobw

It is for version 3.01 (the latest plugin version is 4.01), but this is the last help version I could find...

StainlessS
11th September 2019, 15:04
Thanks Mani, was in plugin docs eh, I was trying to find webpage.

Bout 25% done now, will initially be for SOME avs standard colorspaces only, I will though want avs+ eventually. [will also supply v2.58 plug + x64]

Doin' it summick like this,


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 (x/y)*]
\ float "BlurPower"=1.0, [* 1.0 -> ??? *]
\ Int "ShowMode"=0 [* 0=Overlay Logo Patch(Clipped Logo), 1=Overlay Logo Patch(Clipped) & Border, 2=DeLogo *]
\ Bool "Blank"=false [* Where ShowMode==2 and Blank==True then Blank to Black any border area (border is outside of Clip args) *]
\ )

EDITED:

EDIT: I'm not taking any pixel Aspect Ratio into account for distance, dont think it worth the (small) effort. [EDIT: See SAR above]

EDIT: ShowMode = 1 Example showing Patch Area (after clipping, in Yellowish), Clipped out area (In Reddish), and border Area in Purplish.
Yellowish + Reddish is original non clipped Logo Coords.

Avisource(".\Parade.avi")
Crop(0,0,Width/4*4,height/4*4) # Make Mod 4

ConvertToRGB24 # Internally Converted to RGB32 and back to RGB24 again [Layer() requirement, supports only YUY2 & RGB32].

LogoX = -100 # Can be -ve, Width relative
LogoY = -100 # Can be -ve, Heigth relative
LogoW = -20 # Can be 0 or -ve, Width relative
LogoH = -20 # Can be 0 or -ve, Height relative

# Clipping Coords (inside is valid graphic, outside of it is border/Letterbox)
ClipX = 0 # Black border area, +ve ONLY
ClipY = 0 # ditto
ClipW = -50 # Can be 0 or -ve, Width relative
ClipH = -50 # Can be 0 or -ve, Height relative

BLURPOWER= 1.0
SHOWMODE = 1
BLANK = False

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

https://i.postimg.cc/zXJLG4j2/Uglarm-00.jpg (https://postimages.org/)

Reel.Deel
12th September 2019, 15:29
@VoodooFX

Thank you for this script. I tried it out and I was very pleased with the results.

StainlessS
12th September 2019, 20:23
Function prototype in post #43 updated.

Got the Uglam overlay stuff working fine, but the delogo part was well slow (and did not quite work on initial attempts).
Did some searching and found this source patch file for ffmpeg, cant say it made a lot of sense to me (at first, never used SubVersioning stuff before),
but managed to figure it out a bit but probably a little more time till working OK. Is a fast way to precalc tables for UGLARM interpolation,
unfortunately, they use coords for logo which include the border pixels, and I exclude them, so need a bit of a redo, but getting there.
[also seems to expect valid perimeter pixels all around the logo, whereas I allow for letterbox border overlap of logo, so more changes there too].

Here the patch source code thing that I found on UGLARM search:- https://patchwork.ffmpeg.org/patch/11585/
probably will not make much sense, presume that you are supposed to use some kind of dedicated patch code reader software to be able to understand it.
anyways, I mostly got it figured out [and dropped some dross that was either dormant or did not work].

Anyways, I then (just now) found original source of the Uglarm tables code from ffdshow:- https://sourceforge.net/p/ffdshow-tryout/code/HEAD/tree/trunk/src/imgFilters/TimgFilterLogoaway.cpp
ffdshow stuff makes a lot more sense than the ffmpeg patch file I was working with. Relevant table creation stuff is in TimgFilterLogoaway.cpp functions,


void TimgFilterLogoaway::Tplane::calcUweWeightTable(int w, int h, int power)

void TimgFilterLogoaway::Tplane::uwe(const TlogoawaySettings *cfg)


I've still gotta convert from their definition of logo coords to mine, but at least easier to read.

Leaving this here so I can more easily find it again (ffdshow link), maybe of interest to some others too [incl VDX].
[Also wanna keep record of where I got source from so that I can point to it as per GPL requirements].

Also, here on-line version of Manolito linked LogoAways docs:- http://vander.wojdon.net/virtualdub/ladocs301/logoaway.html

VoodooFX
13th September 2019, 15:20
I'm not taking any pixel Aspect Ratio into account for distance, dont think it worth the (small) effort. [EDIT: See SAR above]


I don't see any practical effect of that, or even theoretical... unless to make a parameters list longer. Thats would be same as adding SAR parameter to Blur() or any other function, or I miss something here!?

StainlessS
13th September 2019, 18:39
I obviously wanted to make the parameter list longer, so as to seem more complicookered, me likes that.

Still not got the damn thing working properley, on last try (using more like the original patch code), it was prodcuing something quite akin
to the mandelbrot stuff, looks well weird. Maybe I see when working, if SAR stuff makes any difference, eliminate if not.
[SAR affects distance calcs for uglarm, so for chroma of eg YUY2 or YV16, should make a fair bit of difference, maybe. SAR auto modified for chroma of YUY2 and YV16].
Although, when I've ever used any delogo thing in eg Vdub, I never bothered with SAR.

EDIT:
https://i.postimg.cc/HLBXTG4m/Uglarm-Client-00.jpg (https://postimages.org/)

https://i.postimg.cc/FsCKF9wD/Uglarm-Client-01.jpg (https://postimages.org/)

EDIT: If there had been a logo in above images, they would certainly have been eliminated.
Had I done above patterns deliberately, I would have been quite proud if it. :)
I bet you mathematicians out there can tell what I'm doin' wrong just by lookin' at it.
EDIT: Gone t' pub.

StainlessS
17th September 2019, 03:33
Uglarm v0.0 Logo Interpolator now posted, Guinea pigs required, Here:- https://forum.doom9.org/showthread.php?t=176891

No idea how it compares to others tested in this thread.

EDIT: Seems a bit slow on YV12 UT_Video FullHD 192x192 logo, bout 11.8 FPS on my crap Core Duo Quad 2.8GHz m/c. [23% CPU usage, x64 version, bout 9FPS x86]

Mani, as you seem to like Uglarm Method, hows bout give it a whirl, with comparison times etc.
(Likely some bugs to iron out, tis still a baby).

StainlessS
29th September 2019, 02:00
Hi VDX, can I request a feature update.
I like to be able to use -ve width and height as in crop, but not quite so keen on being forced to only use -ve values,
so how bout making +ve width and height possible in your loc string thing ?

Below should do it in both your InpaintLoc(), and InpaintDelogo() functions.

InpaintLoc() mod in BLUE

a = int(value(leftstr(loc,posvirg1-1)))
b = int(value(leftstr(rightstr(loc,long-posvirg1),posvirg2-posvirg1-1)))
c = int(value(leftstr(rightstr(loc,long-posvirg2),posvirg3-posvirg2-1)))
d = int(value(rightstr(loc,long-posvirg3)))

c = (c > 0 ) ? a+c-x: c # Added, convert +ve width to -ve width
d = (d > 0 ) ? b+d-y: d # Added, convert +ve height to -ve height

hightlight = blankclip(width=x-a+c,height=y-b+d,color=$96ff2d).converttoRGB32 # EDIT: This depends upon -ve crop values, may do elsewhere in script too.


InpaintDelogo() mod in BLUE

a = int(value(leftstr(loc,posvirg1-1)))
b = int(value(leftstr(rightstr(loc,long-posvirg1),posvirg2-posvirg1-1)))
c = int(value(leftstr(rightstr(loc,long-posvirg2),posvirg3-posvirg2-1)))
d = int(value(rightstr(loc,long-posvirg3)))

c = (c > 0 ) ? a+c-x: c # Added, convert +ve width to -ve width
d = (d > 0 ) ? b+d-y: d # Added, convert +ve height to -ve height


inYV12 = clp.Crop(a,b,c,d).ConvertToYV12
inRGB24 = clp.Crop(a,b,c,d).ConvertToRGB24
inRGB32 = clp.Crop(a,b,c,d).ConvertToRGB32


Instead of converting -ve values to +ve values, I've converted +ve values to your -ve style values, just in case your logic depends upon -ve crop values.


Thankyou in advance.

EDIT:
I now see that you updated since the version script I was using,
Here mod for InpaintLoc() my mod in BLUE, you addition in v1.12 in DarkOrchid [ do similar for InpaintDelogo() ]

a = int(value(leftstr(loc,posvirg1-1)))
b = int(value(leftstr(rightstr(loc,long-posvirg1),posvirg2-posvirg1-1)))
c = int(value(leftstr(rightstr(loc,long-posvirg2),posvirg3-posvirg2-1)))
d = int(value(rightstr(loc,long-posvirg3)))

c = (c > 0 ) ? a+c-x: c # Added, convert +ve width to -ve width
d = (d > 0 ) ? b+d-y: d # Added, convert +ve height to -ve height

Assert (c <= 0 && d <= 0,"""Incorrect "Loc".""")
Assert (a >= 0 && b >= 0,"""Incorrect "Loc".""")
Assert (a%2 == 0 && b%2 == 0 && c%2 == 0 && d%2 == 0,"""Use even numbers for "Loc".""")

hightlight = blankclip(width=x-a+c,height=y-b+d,color=$96ff2d).converttoRGB32

StainlessS
8th December 2019, 13:13
Modified InpaintDelogo_v1.13.avsi.7z @ SendSpace in sig beneath this post. [available for 30 days only, will attach when ascertained that works ok]

# Version 1.11 : 2019/08/31. Public release.
# Version 1.12 : 2019/09/06. Various tweaks. New parameters. "Inflate" and "Deep" changed.
# Version 1.13 : 2019/12/08. Allow -ve LogoX,LogoY, and +ve LogoW,LogoH in Loc string. StainlessS.


# string "Loc" : Select (crop) the part of the picture around the logo.
# Example: Loc="30,420,-540,-30".
# Example: Loc="-200,-100,-30,-20". [ssS: Added, LogoX=Width-200, LogoY=Height-100, LogoX2=Width-30, LogoY2=Height-20]

EDIT: Actually above should be Loc="-200,-100,-30,-20". [ssS: Added, LogoX=Width-200, LogoY=Height-100, LogoX2=Width-30-1, LogoY2=Height-20-1, same as -ve cropping for width and height]

EDIT: OR eg, Loc="-200,-100,30,20". [ LogoX=Width-200, LogoY=Height-100, LogoW=30, LogoH=20]

bugloc2 = (loc == "0,0,-0,-0" || loc == "0,0,0,0") ? true : false # ssS: Added:- || loc == "0,0,0,0"


# assert ( findstr(loc,"-" ) != 0 , """Incorrect "Loc".""") # ssS: Commented OUT, we now allow +ve width and height in loc


Both in InpaintDelogo() and InpaintLoc()
a = (a < 0 ) ? x+a : a # ssS: Added, convert -ve logoX to +ve LogoX
b = (b < 0 ) ? y+b : b # ssS: Added, convert -ve logoY to +ve LogoY
c = (c > 0 ) ? a+c-x: c # ssS: Added, convert +ve width to -ve width
d = (d > 0 ) ? b+d-y: d # ssS: Added, convert +ve height to -ve height



Manolito,

What magic arguments do you use for removing fully opaque logos ?

I've done a mod to VoodooFX InpaintDelogo, v1.13, but dont know how to test it as I cannot get it working.
.

I'm not sure is possible without any kind of analysis, and below will fail if analysis is mandatory ['[I]mask is full' or similar error].

I want to test with something like this.

Import("InpaintDelogo_v1.13.avsi")
WH=512
A=BlankClip(width=WH/2,height=WH/2)
B=A.Invert StackHorizontal(A,B)
StackVertical(Invert)
trim(0,-100) # 100 frames, RGB32

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

Overlay(Last.BlankClip(Width=LogoW,height=LogoH,color=$8080C0),x=LogoX,y=LogoY) # Make dummy logo

loc=RT_string("%d,%d,%d,%d",LogoX,LogoY,LogoW,LogoH) # location of logo

# Return InpaintLoc(loc) # Mark/overlay logo area with 0.5 transparent light green

#InpaintDelogo(loc=loc,mode="Inpaint",mask="d:\EXLOGO\tmp.bmp",AutoMask=1) # NO Idea what to use here for static fully opaque logo, We do not need any kind of analyse, we know where it is.

#Uglarm(LogoX,LogoY,LogoW,LogoH) # test delogo using Uglarm

Return Last

__END__

InpaintDelogo( mask="d:\EXLOGO\tmp.bmp",
\ Automask=0, aMix=0, Loc=loc,
\ Mode="Inpaint",
\ Analyze=1, Fr1=0, Fr2=0, FrS=0, ReAnalyze=0,
\ dPP=3, dPPm=3, Interp=2, InterpM=0, Deep=2,
\ oPP=6, oPPm=3, oTune=0, KillShape=0, Inflate=1, Turbo=0,
\ Sharpness=45, PreBlur=6.5, PostBlur=4.0, Radius=8.0, prePP=0,
\ GrainPP=2,
\ Show=0, mShow=0, rSize=4)


Baseclip
https://i.postimg.cc/GTKQrxPp/Base0.jpg (https://postimg.cc/GTKQrxPp)

Dummy Logo
https://i.postimg.cc/56krCfv2/Dummy-Logo1.jpg (https://postimg.cc/56krCfv2)

InpaintLoc marked
https://i.postimg.cc/NLdJ3Qdk/In-Paint-Loc.jpg (https://postimg.cc/NLdJ3Qdk)

Uglarm delogo test
https://i.postimg.cc/v4fvZytj/Uglarm.jpg (https://postimg.cc/v4fvZytj)

EDIT: VoodooFX dont seem to have been around lately, no indication on user profile when he/she/it last visited. [no idea why last visit missing from user profile, is usually there]