InpaintFunc

From Avisynth wiki
(Difference between revisions)
Jump to: navigation, search
m (1 revision)
(requirement updates)
 
(8 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Filter|Reuf Toc|1.13|[[Media:InpaintFunc.avs|InpaintFunc.avs]]|Logo removal|
+
{{FilterCat4|External_filters|Scripts|Restoration_filters|Logo_Removal}}
YV12, YUY2, RGB24, RGB32
+
{{Filter3
 +
|Reuf Toc, StainlessS
 +
|1.15
 +
|[https://pastebin.com/raw/ZSD7P9ZM InpaintFunc_v1.15.avs]
 +
|Logo removal
 +
|
 
|}}
 
|}}
{{Template:FuncDef|InpaintFunc(clip clp, string "mask", string "loc", float "AR", string "mode",int "speed", int "pp", int "ppmode", bool "reset", float "radius", float "sharpness", float "preblur", float"postblur")}}
 
  
 +
== Description ==
 +
Uses AVSInpaint to remove a logo, such as that of a TV station, from a specified clip. Image Inpainting is the art of restoring destroyed parts of an image by using information of valid parts of the image in a way, so that the human eye does not recognize the damaged areas (at least not at a first sight). In video processing image inpainting is often applied to videos in order to remove TV station logos.
  
{{Template:FuncDef|InpaintAssist(clip clp, string "loc", string "alignment")}}
 
  
== Abstract ==
+
== Requirements ==
InpaintFunc is a new delogo function using AVSInpaint.dll an AviSynth C plugin developed by AMSS. See thread : http://forum.doom9.org/showthread.php?t=133682 to download this plugin and get more information about it. Just some advice : AVSInpaint plugin is rather slow so be patient ;-)
+
* [x86]: [[AviSynth+]] or [http://sourceforge.net/projects/avisynth2/ AviSynth 2.6]
 +
* [x64]: [[AviSynth+]]
 +
* Supported color formats: [[RGB32]], [[RGB24]], [[YUY2]], [[YV12]]
  
== Requires Filters ==
+
===Required Plugins===
*[[AVSInpaint]]
+
Latest versions of the following filters are recommended unless stated otherwise.<br>
 +
*[[AvsInpaint]]
 +
*[[MaskTools2]]
  
AVSInpaint is an avisynth C plugin, don't forget to add '''loadCplugin("xxx\AVSInpaint.dll")''' in your script before calling this function !!!
+
AvsInpaint is an AviSynth C plugin. If you're using 'classic' AviSynth you'll have to add '''[[LoadPlugin#LoadCPlugin|loadCplugin("xxx\AVSInpaint.dll")]]''' in your script before calling this function. AviSynth+ can auto-load C-plugins so the LoadCPlugin() statement is not necessary in this case.
 +
<br>
 +
<br>
 +
== [[Script variables|Syntax and Parameters]] ==
 +
:{{Template:FuncDef|InpaintFunc(clip clp, string "mask", string "loc", float "AR", string "mode",int "speed", int "pp", int "ppmode", bool "reset", float "radius", float "sharpness", float "preblur", float"postblur")}}
  
== Background Information ==
 
Image Inpainting is the art of restoring destroyed parts of an image by using information of valid parts of the image in a way, so that the human eye does not recognize the damaged areas (at least not at a first sight). In video processing image inpainting is often applied to videos in order to remove TV station logos.
 
  
== Description ==
+
::{{Par2|clp|clip|last}}
Uses AVSInpaint to remove a logo, such as that of a TV station, from a specified clip.
+
:::The clip to be "delogo-ed".
  
{{Par|clp|clip|last}}
 
The clip to be "delogo-ed".
 
  
{{Par|mask|string|null}}
+
::{{Par2|mask|string|null}}
Path to the mask of the logo. The mask is a black and white picture. Areas where the logo is are white, the rest is black. Example : mask="C:\my_mask.bmp"
+
:::Path to the mask of the logo. The mask is a black and white picture. Areas where the logo is are white, the rest is black. Example : mask="C:\my_mask.bmp"
 
+
{{Par|loc|string|null}}
+
Select the region of the picture where the logo to remove is.
+
See the table :
+
  
  
 +
::{{Par2|loc|string|null}}
 +
:::Select the region of the picture where the logo to remove is. See the table :
 
               ______________          ______________
 
               ______________          ______________
 
               | TL | TC |TR |          | X1 | X2 |X3 |
 
               | TL | TC |TR |          | X1 | X2 |X3 |
Line 40: Line 47:
 
               |____|____|___|          |____|____|___|
 
               |____|____|___|          |____|____|___|
  
 +
:::If the logo you want to remove is in the top right corner, then you can choose either loc="TR" or loc="x3". But if you're not satisfied with those presets, you can enter your own parameters by pixels to isolate the logo.
  
If the logo you want to remove is in the top right corner, then you can choose either loc="TR" or loc="x3".
+
:::Example : loc = "0,300,-440,-20". Spaces are not allowed in "loc" parameter.
But if you're not satisfied with those presets, you can enter your own parameters by pixels to isolate the logo.
+
  
example : loc = "0,300,-440,-20". Spaces are not allowed in "loc" parameter.
 
  
{{Par|AR|float| 1.0}}
+
::{{Par2|AR|float| 1.0}}
The Sample Aspect Ratio of your video. E.g. : 16/9, 4/3...  (Default 1.0). This value is used to calculate the PAR of your video. If you don't set this parameter, then PAR will be set to 1:1. When you set the AR, take care to add ".0" to your values if you use exact value (16/9 or 4/3). Example : AR=16.0/9.0 or AR=4.0/3.0 .
+
:::The Sample Aspect Ratio of your video. E.g. : 16/9, 4/3...  (Default 1.0). This value is used to calculate the PAR of your video. If you don't set this parameter, then PAR will be set to 1:1. When you set the AR, take care to add ".0" to your values if you use exact value (16/9 or 4/3). Example : AR=16.0/9.0 or AR=4.0/3.0 .
  
{{Par|mode|string|"both"}}
 
3 Choices (default both) : <br>
 
*Deblend : If the logo is transparent, use this mode. <br>
 
*Inpaint : If the logo is opaque, use this mode. <br>
 
*Both    : If the logo is both opaque and transparent, use this mode. <br>
 
  
{{Par|speed|int|5}}
+
::{{Par2|mode|string|"both"}}
With this parameter you can speed up this function by trimming the clip analyzed by AnalyseLogo. A value of 20 means that 100% of clip will be analyzed. With a value of 1, only 5% will be analyzed. (min value 1, max value 20, default 5).
+
:::3 Choices (default both) : <br>
 +
:::*Deblend : If the logo is transparent, use this mode. <br>
 +
:::*Inpaint : If the logo is opaque, use this mode. <br>
 +
:::*Both    : If the logo is both opaque and transparent, use this mode. <br>
  
{{Par|PPmode|int|0}}
 
If you want to apply post-processing, 3 modes are available. Default is 0 (disabled)
 
*Mode 1 : Blur all the area where logo was present.
 
*Mode 2 : Blur all the area where logo was present using TemporalSoften and SpatialSoften.
 
*Mode 3 : Blur only the edge of logo area using TemporalSoften and SpatialSoften..
 
  
{{Par|PP|int|50}}
+
::{{Par2|speed|int|5}}
Strength of the post-processing. Default is 50 (min value 0, max value 100)
+
:::With this parameter you can speed up this function by trimming the clip analyzed by AnalyseLogo. A value of 20 means that 100% of clip will be analyzed. With a value of 1, only 5% will be analyzed. (min value 1, max value 20, default 5).
A 0 value will disable post processing, 100 will process at full strength.
+
  
{{Par|Reset|bool|False}}
 
InpaintFunc contain a feature that allow to not compute logo analysis when it was already done.
 
By setting Reset to true, logo analysis is always computed. Default is false.
 
  
{{Par|Radius|Float|8.0}}
+
::{{Par2|PPmode|int|0}}
Radius around a damaged pixel from where values are taken when the pixel is inpainted. Bigger values prevent inpainting in the wrong direction, but also create more blur.
+
:::If you want to apply post-processing, 3 modes are available. Default is 0 (disabled)
 +
:::*Mode 1 : Blur all the area where logo was present.
 +
:::*Mode 2 : Blur all the area where logo was present using TemporalSoften and SpatialSoften.
 +
:::*Mode 3 : Blur only the edge of logo area using TemporalSoften and SpatialSoften..
  
{{Par|Sharpness|Float|75.0}}
 
Higher values can prevent blurring caused by high Radius values.
 
  
{{Par|PreBlur|Float|8.0}}
+
::{{Par2|PP|int|50}}
Standard deviation of the blur which is applied to the image before the structure tensor is computed. Higher values help connecting isophotes which have been cut by the inpainting region, but also increase CPU usage. PreBlur=0.0 disables pre-blurring.
+
:::Strength of the post-processing. Default is 50 (min value 0, max value 100)
 +
:::A 0 value will disable post processing, 100 will process at full strength.
  
{{Par|PostBlur|Float|4.0}}
 
Standard deviation of the blur which is applied to the structure tensors before they are used to determine the inpainting direction. Higher values help gather more directional information when there are only few valid pixels available, but increases CPU usage.
 
  
{{Par|Show|Bool|False}}
+
::{{Par2|Reset|bool|False}}
Allow the user to see the differents steps of the delogoing. Are displayed the source, the repaired, the repaired post-processed, the mask, the repair masks (edge and global), the color mask, the alpha mask and the inpaint mask.
+
:::InpaintFunc contain a feature that allow to not compute logo analysis when it was already done.
 +
:::By setting Reset to true, logo analysis is always computed. Default is false.
 +
 
 +
 
 +
::{{Par2|Radius|Float|8.0}}
 +
:::Radius around a damaged pixel from where values are taken when the pixel is inpainted. Bigger values prevent inpainting in the wrong direction, but also create more blur.
 +
 
 +
 
 +
::{{Par2|Sharpness|Float|75.0}}
 +
:::Higher values can prevent blurring caused by high Radius values.
 +
 
 +
 
 +
::{{Par2|PreBlur|Float|8.0}}
 +
:::Standard deviation of the blur which is applied to the image before the structure tensor is computed. Higher values help connecting isophotes which have been cut by the inpainting region, but also increase CPU usage. PreBlur=0.0 disables pre-blurring.
 +
 
 +
 
 +
::{{Par2|PostBlur|Float|4.0}}
 +
:::Standard deviation of the blur which is applied to the structure tensors before they are used to determine the inpainting direction. Higher values help gather more directional information when there are only few valid pixels available, but increases CPU usage.
 +
 
 +
 
 +
::{{Par2|Show|Bool|False}}
 +
:::Allow the user to see the differents steps of the delogoing. Are displayed the source, the repaired, the repaired post-processed, the mask, the repair masks (edge and global), the color mask, the alpha mask and the inpaint mask.
  
  
 
----
 
----
 +
 +
===InpaintAssist===
  
  
Line 94: Line 112:
 
With HD footage, the delogo process is slow due to the resolution (especialy for analysis) and to maximize speed, it is adviced to reduce the size of the cropped clip by setting your own crop values.
 
With HD footage, the delogo process is slow due to the resolution (especialy for analysis) and to maximize speed, it is adviced to reduce the size of the cropped clip by setting your own crop values.
  
*If you don't specify a loc value, this function will display your clip divised in 9 parts (the nine loc preset of InpaintFunc) with the crop values for each one in order to give you an idea about the values to use.
+
*If you don't specify a loc value, this function will display your clip divided in 9 parts (the nine loc preset of InpaintFunc) with the crop values for each one in order to give you an idea about the values to use.
  
*After that step, you can enter your own loc values and check they are correct. The selected area will be hightlighted. Keep in mind you have to keep a little border around the logo since inpainting use nearby pixels to compute the hidden ones.
+
*After that step, you can enter your own loc values and check they are correct. The selected area will be highlighted. Keep in mind you have to keep a little border around the logo since inpainting use nearby pixels to compute the hidden ones.
  
  
{{Par|loc|string|null}}
+
:{{Template:FuncDef|InpaintAssist(clip clp, string "loc", string "alignment")}}
Select the part of the picture where is the logo to remove. Same as InpaintFunc loc parameter
+
  
{{Par|alignment|string|"top"}}
+
::{{Par2| |clip| }}
Alignment of the text. "Top", "Center" and "Bottom" are allowed
+
:::Input clip.
  
== Example ==
+
::{{Par2|loc|string|null}}
 +
:::Select the part of the picture where is the logo to remove. Same as InpaintFunc loc parameter
  
  LOADCPLUGIN("AVSINPAINT.DLL")
+
::{{Par2|alignment|string|"top"}}
 +
:::Alignment of the text. "Top", "Center" and "Bottom" are allowed
 +
 
 +
 
 +
== Example ==
 +
<pre>
 +
  LoadCPlugin("AVSInpaint.dll")
 
  Import("InpaintFunc.avs")
 
  Import("InpaintFunc.avs")
avisource("videowithlogo.avi")
 
InpaintFunc(last, mask="logo.bmp", loc="br", AR=4.0/3.0, mode="both", speed=10, ppmode=3, pp=75)
 
  
== Links ==
+
AviSource("videowithlogo.avi")
Download [[Media:InpaintFunc.avs|InpaintFunc.avs]] Current version (recommended).
+
InpaintFunc(last, mask="logo.bmp", loc="br", AR=4.0/3.0, mode="both", speed=10, ppmode=3, pp=75)
 +
</pre>
  
Download [http://forum.doom9.org/showpost.php?p=1086451&postcount=1 AVSInpaint] from this post.
 
  
[[Category:External filters]]
+
== External Links ==
 +
*[http://forum.doom9.org/showthread.php?t=172208 Doom9 Forum] - InpaintFunc.avs - Different result depending on AviSynth version
 +
*[http://forum.doom9.org/showthread.php?t=162124 Doom9 Forum] - Help with InpaintFunc
 +
*[[Media:InpaintFunc.avs|InpaintFunc.avs v1.13]]
 +
*[https://pastebin.com/raw/X6v36CQ8 InpaintFunc_v1.14.avs]
 +
<br>
 +
<br>
 +
-----------------------------------------------
 +
'''Back to [[External_filters#Logo_Removal|External Filters]] &larr;'''

Latest revision as of 15:59, 7 May 2020

Abstract
Author Reuf Toc, StainlessS
Version 1.15
Download InpaintFunc_v1.15.avs
Category Logo removal
License
Discussion

Contents

[edit] Description

Uses AVSInpaint to remove a logo, such as that of a TV station, from a specified clip. Image Inpainting is the art of restoring destroyed parts of an image by using information of valid parts of the image in a way, so that the human eye does not recognize the damaged areas (at least not at a first sight). In video processing image inpainting is often applied to videos in order to remove TV station logos.


[edit] Requirements

[edit] Required Plugins

Latest versions of the following filters are recommended unless stated otherwise.

AvsInpaint is an AviSynth C plugin. If you're using 'classic' AviSynth you'll have to add loadCplugin("xxx\AVSInpaint.dll") in your script before calling this function. AviSynth+ can auto-load C-plugins so the LoadCPlugin() statement is not necessary in this case.

[edit] Syntax and Parameters

InpaintFunc(clip clp, string "mask", string "loc", float "AR", string "mode",int "speed", int "pp", int "ppmode", bool "reset", float "radius", float "sharpness", float "preblur", float"postblur")


clip  clp = last
The clip to be "delogo-ed".


string  mask = null
Path to the mask of the logo. The mask is a black and white picture. Areas where the logo is are white, the rest is black. Example : mask="C:\my_mask.bmp"


string  loc = null
Select the region of the picture where the logo to remove is. See the table :
             ______________           ______________
             | TL | TC |TR |          | X1 | X2 |X3 |
             |____|____|___|          |____|____|___|
             | ML | MC |MR |    or    | Y1 | Y2 |Y3 |
             |____|____|___|          |____|____|___|
             | BL | BC |BR |          | Z1 | Z2 |Z3 |
             |____|____|___|          |____|____|___|
If the logo you want to remove is in the top right corner, then you can choose either loc="TR" or loc="x3". But if you're not satisfied with those presets, you can enter your own parameters by pixels to isolate the logo.
Example : loc = "0,300,-440,-20". Spaces are not allowed in "loc" parameter.


float  AR = 1.0
The Sample Aspect Ratio of your video. E.g. : 16/9, 4/3... (Default 1.0). This value is used to calculate the PAR of your video. If you don't set this parameter, then PAR will be set to 1:1. When you set the AR, take care to add ".0" to your values if you use exact value (16/9 or 4/3). Example : AR=16.0/9.0 or AR=4.0/3.0 .


string  mode = "both"
3 Choices (default both) :
  • Deblend : If the logo is transparent, use this mode.
  • Inpaint : If the logo is opaque, use this mode.
  • Both  : If the logo is both opaque and transparent, use this mode.


int  speed = 5
With this parameter you can speed up this function by trimming the clip analyzed by AnalyseLogo. A value of 20 means that 100% of clip will be analyzed. With a value of 1, only 5% will be analyzed. (min value 1, max value 20, default 5).


int  PPmode = 0
If you want to apply post-processing, 3 modes are available. Default is 0 (disabled)
  • Mode 1 : Blur all the area where logo was present.
  • Mode 2 : Blur all the area where logo was present using TemporalSoften and SpatialSoften.
  • Mode 3 : Blur only the edge of logo area using TemporalSoften and SpatialSoften..


int  PP = 50
Strength of the post-processing. Default is 50 (min value 0, max value 100)
A 0 value will disable post processing, 100 will process at full strength.


bool  Reset = False
InpaintFunc contain a feature that allow to not compute logo analysis when it was already done.
By setting Reset to true, logo analysis is always computed. Default is false.


Float  Radius = 8.0
Radius around a damaged pixel from where values are taken when the pixel is inpainted. Bigger values prevent inpainting in the wrong direction, but also create more blur.


Float  Sharpness = 75.0
Higher values can prevent blurring caused by high Radius values.


Float  PreBlur = 8.0
Standard deviation of the blur which is applied to the image before the structure tensor is computed. Higher values help connecting isophotes which have been cut by the inpainting region, but also increase CPU usage. PreBlur=0.0 disables pre-blurring.


Float  PostBlur = 4.0
Standard deviation of the blur which is applied to the structure tensors before they are used to determine the inpainting direction. Higher values help gather more directional information when there are only few valid pixels available, but increases CPU usage.


Bool  Show = False
Allow the user to see the differents steps of the delogoing. Are displayed the source, the repaired, the repaired post-processed, the mask, the repair masks (edge and global), the color mask, the alpha mask and the inpaint mask.



[edit] InpaintAssist

Rev 1.11 introduce a subfunction, InpaintAssist, that can be used to help you in order to set your own crop values to isolate the logo to remove. With HD footage, the delogo process is slow due to the resolution (especialy for analysis) and to maximize speed, it is adviced to reduce the size of the cropped clip by setting your own crop values.

  • If you don't specify a loc value, this function will display your clip divided in 9 parts (the nine loc preset of InpaintFunc) with the crop values for each one in order to give you an idea about the values to use.
  • After that step, you can enter your own loc values and check they are correct. The selected area will be highlighted. Keep in mind you have to keep a little border around the logo since inpainting use nearby pixels to compute the hidden ones.


InpaintAssist(clip clp, string "loc", string "alignment")
clip   =
Input clip.
string  loc = null
Select the part of the picture where is the logo to remove. Same as InpaintFunc loc parameter
string  alignment = "top"
Alignment of the text. "Top", "Center" and "Bottom" are allowed


[edit] Example

 LoadCPlugin("AVSInpaint.dll")
 Import("InpaintFunc.avs")

 AviSource("videowithlogo.avi")
 InpaintFunc(last, mask="logo.bmp", loc="br", AR=4.0/3.0, mode="both", speed=10, ppmode=3, pp=75)


[edit] External Links




Back to External Filters