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 9th December 2019, 19:39   #61  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 7,477
Any/all changes that you dont like, remove [or just miss them out all together in v1.14], I can easily make a stub to amend loc from outside of your script, not a problem at all.

The thing I'm currently doing (s_exlogo2) is not in anyway competition for your script, has different intent, I wanna be able to just splat any rectangular problem areas without having to do any analysis.

Quote:
Found some old testing files, just need to remember and understand all this new stuff in your plugin.
Aint my plugin, is yours, you gets all the blame for everything
__________________
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 ???
StainlessS is offline   Reply With Quote
Old 9th December 2019, 19:48   #62  |  Link
VoodooFX
Registered User
 
Join Date: Sep 2008
Posts: 82
By default InpaintDelogo doesn't do any analysis too, only if you want to get the mask automatically or deblend the logo.
VoodooFX is offline   Reply With Quote
Old 27th December 2019, 00:48   #63  |  Link
TCmullet
Registered User
 
Join Date: Nov 2003
Posts: 326
I've tried to look over everything and absorb what I could. Your built-in two manuals leave out much. Here's where I'm stuck now:

> 2) Get frames numbers for manual "Analyze".

What do I do with the range of frame numbers that I want the analysis to be based on?

BTW, I will be replacing rm_logo logic. My scripts have commented out code which was used to do the analysis, then further down was my runtime code.
TCmullet is offline   Reply With Quote
Old 27th December 2019, 11:16   #64  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 7,477
@ TcMullet,

I'm off to bed in a minute, but will come back later.

@ VoodooFX,
I've removed the InPaintDelogo v1.13 pretender script from SendSpace, its gone 4E4. [forever]

Have done a stub function just to manufacture InPaintDelogo style Loc string, add it to your script if your like it, if not then no sweat.

Code:
Function MakeLoc(clip c,Int x, Int y, Int w, Int h) { # https://forum.doom9.org/showthread.php?p=1893966#post1893966
/*
    Make Loc string for VoodooFX InPaintDelogo.
    Input X and Y, where -ve, is relative to c.Width or c.Height, and are converted to +ve X and Y in result string.
    Input W and H, where 0 or -ve, is relative c.Width or c.Height [as in Crop()],
        Where +ve, are converted to -ve W and H in result string [as required by InPaintDelogo].
    Allows to make Loc string programmatically using flexible coord system and not locked into hand editing Loc string.

       ColorBars                      # 640,480
       S=MakeLoc(   0,   0,  0,  0)   # "0,0,-0,-0"
       S=MakeLoc( 540, 380,-40,-40)   # "540,380,-40,-40"
       S=MakeLoc(-100,-100, 60, 60)   # "540,380,-40,-40"
       S=MakeLoc( 540, 380, 60, 60)   # "540,380,-40,-40"
       S=MakeLoc(-100,-100,-40,-40)   # "540,380,-40,-40"
*/
    c
    # First, Ensure/Convert X,Y,W,H ALL +ve
    x = (x >= 0) ? x : Width  + x
    y = (y >= 0) ? y : Height + y
    w = (w >  0) ? w : Width  - x + w
    h = (h >  0) ? h : Height - y + h
    # Check validity
    Assert(0 <= x <  Width    ,String(x,"MakeLoc: 0 <= X(%.0f)") + String(Width  ," < Width(%.0f)" ))
    Assert(0 <= y <  Height   ,String(y,"MakeLoc: 0 <= Y(%.0f)") + String(Height ," < Height(%.0f)"))
    Assert(1 <= w <= Width -x ,String(w,"MakeLoc: 1 <= W(%.0f)") + String(Width  ," <= Width-X(%.0f")  + String(x ," - %.0f)"))
    Assert(1 <= h <= Height-y ,String(h,"MakeLoc: 1 <= H(%.0f)") + String(Height ," <= Height-Y(%.0f") + String(y ," - %.0f)"))
    # Output string:  +ve X,Y :: -ve W,H, Ensure all (even W=0 and H=0) flagged as -ve eg -0
    return String(x,"%.0f") + String(y,",%.0f") + String(Abs(x+w-Width),",-%.0f") +String(Abs(y+h-Height),",-%.0f")
}
EDIT: If you DONT like the -ve x,y options, then can just delete the above lines in RED, and if you do include above without -ve x,y,
then please rename function to some other name, I dont want it to conflict with my stub. [you would likely want to edit the description too of course].
__________________
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; 27th December 2019 at 11:48.
StainlessS is offline   Reply With Quote
Old 28th December 2019, 00:51   #65  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,277
Quote:
Originally Posted by TCmullet View Post
Here's where I'm stuck now:

> 2) Get frames numbers for manual "Analyze".

What do I do with the range of frame numbers that I want the analysis to be based on?
Forget doing an analysis pass. Make your own logo BMP, find the coordinates for the location (10-12 pixels outside of the logo coordinates). and go right to InpaintDelogo. I've been using this script, copied from the manual, with success (adjust for your BMP location and location coordinates):

InpaintDelogo( mask="G:\Jugnu\Logo.bmp",
\ Automask=0, aMix=0, Loc="44,34,-524,-386",
\ Mode="Inpaint",
\ Analyze=1, Fr1=0, Fr2=0, FrS=0)


Others such as manolito, VoodooX, or StainlessS might want to make suggestions. I'm not even sure I need all that, but it works quickly and it works well.

Last edited by manono; 28th December 2019 at 00:54.
manono is offline   Reply With Quote
Old 28th December 2019, 08:11   #66  |  Link
VoodooFX
Registered User
 
Join Date: Sep 2008
Posts: 82
December is very busy... I don't have much time StainlessS.

Quote:
Originally Posted by TCmullet View Post
I've tried to look over everything and absorb what I could. Your built-in two manuals leave out much. Here's where I'm stuck now:

> 2) Get frames numbers for manual "Analyze".

What do I do with the range of frame numbers that I want the analysis to be based on?

BTW, I will be replacing rm_logo logic. My scripts have commented out code which was used to do the analysis, then further down was my runtime code.
Everything is in the manual, you just need to read it. Some part of it about frames:

Quote:
3 - Manual analysis. This method is best, but you need one frame where
# logo area is in a solid black/dark background and another in a solid
# white/bright background. Blacker/whiter - better. These two frames must
# be set with "Fr1" & "Fr2" parameters and optional "FrS".
VoodooFX is offline   Reply With Quote
Old 29th December 2019, 00:01   #67  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 2,722
I agree that using InpaintDelogo can be a little bit confusing at first - I found it confusing even with a lot of experience from other delogo plugins...

In this post I will try to remove some of the confusion. To achieve this I will only refer to the "Inpaint" mode which is meant for opaque logos. The two other modes ("Deblend" and "Both") are meant for semi-transparent logos, they try to reconstruct the original pixels behind the semi-transparent logo. This makes these modes much more complex and slower, and I found that the result oftentimes does not justify the effort.

For the "Inpaint" mode only one "base mask" is needed. The additional Alpha and Color masks are not needed at all.

This is the basic work flow:
1. Create a "base mask". This is an image file with the identical size of the source clip where the logo itself is all white and the rest of the image is all black. Save it as a BMP file to your HDD.

2. Determine the coordinates for the "Loc" parameter. The dimensions need to be about 10 pixels larger than the logo, and the format is identical to the AviSynth Crop parameters.

3. Call the "InpaintDelogo" function for the logo removal. Use the parameters for the mask file location and the Loc parameter with the coordinates which you have determined.


The InpaintDelogo plugin includes methods to do the #1 and #2 tasks, but it is in no way required to use these methods. For many users it may be much easier to perform these steps manually without using the plugin functions.

Have a look at manono's script two posts above. He does steps #1 and #2 manually, and his final logo removal call can even be stripped down considerably. His original script can be reduced to:
InpaintDelogo(mask="G:\Jugnu\Logo.bmp", Loc="44,34,-524,-386", Mode="Inpaint")

Especially the "Analyze=1" should not be used here. When the mode is set to "Inpaint" then "Analyze=0" will be forced unconditionally. This is because the base mask is already there, and the "Inpaint" mode does not need additional masks which would need analyzing.

For better speed you can play with the "Turbo" parameter, but this is basically it. If you are familiar with using a photo editor to create the mask then this will be your fastest method.


If your are like me and do not feel comfortable with image editors like PhotoShop then it may be a good idea to use the InpaintDelogo plugin to create the required base mask automatically. The "InpaintDelogo" function needs to be called with the "AutoMask=1" parameter for this. With this parameter the function will ONLY CREATE A MASK, nothing else. To actually remove the logo the function has to be called for a second time without the "AutoMask" parameter.

First you need to determine the "Loc" coordinates and enter them into the "Loc" parameter. Then you need to decide which "Analyze" method you want to use for the mask creation. The best and fastest method for the "Inpaint" mode is "Analyze=4". You need to find a source frame where the logo is surrounded by black. For real world movies such a frame can usually be found at the start of the movie or at the very end. The frame number of such a frame needs to be entered with the "Fr1" parameter.

If you cannot find a source frame where the logo is surrounded by black then you need to use the "Analyze=1" method. With this method 3% of the source will be analyzed for the mask creation. This takes time, especially for HD sources. For longer sources you can use this hack to speed up the mask creation:
Quote:
If you use the "Analyze=1" parameter for the AutoMask creation then 3% of the source clip will be used for analyzing. For a longer movie (duration 90 min or above) this takes a long time. You can use "Trim", but for me I get better results after specifying a lower percentage for analyzing. I edited the InpaintDelogo.avsi file and replaced "every=33" with "every=400", and this is way faster without damaging the mask.
So if you decide to use the AutoMask feature of the plugin your first call to the "InpaintDelogo" function should look similar to this:
Quote:
Loc="22,12,-588,-328"
InpaintDelogo(automask=1, analyze=4, fr1=10329, mask="d:\logomask.bmp", Loc=Loc)
Or like this:
Quote:
Loc="22,12,-588,-328"
InpaintDelogo(automask=1, analyze=1, mask="d:\logomask.bmp", Loc=Loc)
And the second call for the actual logo removal could look similar to this one:
Quote:
Loc="22,12,-588,-328"
InpaintDelogo(mask="d:\logomask.bmp", Loc=Loc, Mode="Inpaint", Turbo=0)

Hint for better speed if you are downscaling your source:

The logo removal will be much faster if you apply it after the resizer (when downscaling). Of course this also means that you need to use a downscaled image for creating the mask.


Cheers
manolito

Last edited by manolito; 29th December 2019 at 01:25.
manolito is offline   Reply With Quote
Old 29th December 2019, 00:41   #68  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,277
Quote:
Originally Posted by manolito View Post
His original script can be reduced to:
InpaintDelogo(mask="G:\Jugnu\Logo.bmp", Loc="44,34,-524,-386", Mode="Inpaint")
Thank you very much. I figured it could be streamlined but hadn't gotten around to playing with it as I was just so happy with the way it was working.

Quote:
If you are familiar with using a photo editor to create the mask then this will be your fastest method.
Which is why I said to forget analyzing the video and just create your own logo BMP. Any photo editor can do the job. I use the freeware PhotoFiltre.

Last edited by manono; 29th December 2019 at 00:49.
manono is offline   Reply With Quote
Old 29th December 2019, 01:19   #69  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 2,722
Quote:
Originally Posted by manono View Post
Any photo editor can do the job. I use the freeware PhotoFiltre.
Hey manono,

looks like we have similar preferences. I have been using PhotoFiltre exclusively for many years now. But I still am not an expert with layers and masks, I just don't do much photo editing...

Happy New Year
manolito
manolito is offline   Reply With Quote
Old 29th December 2019, 03:02   #70  |  Link
manono
Moderator
 
Join Date: Oct 2001
Location: Hawaii
Posts: 7,277
Quote:
Originally Posted by manolito View Post
I just don't do much photo editing...
Me neither. About all I use it for is mask creation for logos and for parts of frames where filters are to be applied, and then its Gaussian Blur filter for feathering when needed.

Oh, and for replacing parts of artifacted frames with bits from nearby good frames. All simple stuff. And all for use in AviSynth scripts.
manono is offline   Reply With Quote
Old 29th December 2019, 10:22   #71  |  Link
RieGo
Registered User
 
Join Date: Nov 2009
Posts: 59
i love this plugin!
my personal workflow (no need to create mask):
-find logo area with InpaintLoc()
-find 30+ frames with logo on black background (mostly at start or end of video)
-find 30+ frames with logo on white(ish) background

Code:
InpaintDelogo(mask="tmp.bmp",Automask=1,Loc="x,x,-x,-x", Mode="Both", Analyze=3,Fr1=x,Fr2=x,FrS=3)
now there are 2 things which still are a bit annoying:
-loc parameter would be great to be used as "left,top,width,height" imo
-whenever Automask is enabled, staxrip and probably avisynth doesn't generate a valid output, so i need to first analyze and then disable automask

thanks dev for this great plugin, this really helps a lot!
next improvement would be finding black/white frames on its own
RieGo is offline   Reply With Quote
Old 29th December 2019, 14:05   #72  |  Link
manolito
Registered User
 
manolito's Avatar
 
Join Date: Sep 2003
Location: Berlin, Germany
Posts: 2,722
Quote:
Originally Posted by RieGo View Post
-loc parameter would be great to be used as "left,top,width,height" imo
Have a look at this script by StainlessS:
https://forum.doom9.org/showthread.p...66#post1893966
It will convert your input to the required format for InpaintDelogo.


Quote:
-whenever Automask is enabled, staxrip and probably avisynth doesn't generate a valid output, so i need to first analyze and then disable automask
This is not a bug, it's a feature...
From the manual:
Quote:
# Int "Automask" : Generates a base mask of the logo.
# "Analyze" (and its sub-parameters, except "ReAnalyze"), "aMix", "mask" and
# "Loc" parameters will be used.
# "Loc" would be best 10(no less) pixels from the logo edges.
# Needs "mask" defined with path to imaginary bmp picture, that's where
# a base mask will be generated.
# Will re-analyze on every script load. Fastest and best results will be
# with manual "Analyze".
#
# 0 - Off (default).
# 1 - On. Generates a mask, doesn't do anything else when "On".

Cheers
manolito
manolito is offline   Reply With Quote
Old 30th December 2019, 11:26   #73  |  Link
RieGo
Registered User
 
Join Date: Nov 2009
Posts: 59
Quote:
Originally Posted by manolito View Post
Have a look at this script by StainlessS:
https://forum.doom9.org/showthread.p...66#post1893966
It will convert your input to the required format for InpaintDelogo.
Thanks! i missed that one
RieGo is offline   Reply With Quote
Reply

Tags
avsinpaint, delogo, inpaint, remove, watermark

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 09:56.


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