AvsInpaint

From Avisynth wiki
Revision as of 06:33, 1 April 2020 by Reel.Deal (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Abstract
Author AMSS0815, pinterf
Version v1.2
Download AvsInpaint-v1.2.7z
Category Logo removal
License
Discussion Doom9 Forum

Contents

Description

Image Inpainting is the art of restoring destroied 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. This plugin comes with the intention to provide a suit for the removal of logos, whether opaque or transparent. It provides algorithms for these tasks:

  • Logo detection: An obstacle is analyzed closely after being masked roughly by the user. The exact color map of the logo is determined as well as its alpha mask.
  • Deblending: Given the color image and alpha mask of an overlayed logo, the logo is removed where it is not opaque.
  • Logo inpainting: Opaque parts of the logo are interpolated. A fast method is used which has been published recently by Folkmar Bornemann and Tom März and which is roughly described below.

Finally, a function for calculating the distance function of a mask is provided, which can be used to expand or inflate masks as well as to provide smooth blending masks.

Requirements


Syntax and Parameters

Inpaint Function

InpaintLogo restores masked parts of video frames by interpolation with non-masked parts of the frame. Each masked pixel will be inpainted by averaging surrounding pixels. The weights of this averaging are determined by calculating a special structure tensor that contains information about the directions of isophotes near that pixel.

InpaintLogo (clip Clip, clip "Mask", float "Radius", float "Sharpness", float "PreBlur", float "PostBlur", float "ChromaWeight", float "PreBlurSize", float "PostBlurSize", bool "ChromaTensor", float "PixelAspect", int "Steps")


clip   =
Input clip; the damaged source clip. All color spaces are allowed. If no Mask is provided, the source clip must be RGB32 and the alpha channel is used as mask (see Mask for details). Otherwise all color channels of Clip will be inpainted. The resulting clip will have the same properties as the source clip.


clip  Mask =
Mask defines the parts of the video which will be treated by the plugin. This clip may either have a YUV colorspace (the Y channel is used) or RGB32 (the alpha channel is used). All pixels of the source clip where this mask has values greater than 127 will be inpainted. The mask clip must have the same (spatial) dimensions as the source clip. Moving logos are allowed: If the mask changes in time, the inpainted region in the source clip will change accordingly. If the logo is fixed (hence all mask frames are equal), the mask clip should be trimmed to one single frame indicating a static logo to the function. Since each movement of the inpainting region causes a lot new calculations, inpainting static logos is much faster.


float  Radius = 5.0
Radius describes the neighborhood of a damaged pixel from where values are taken when the pixel is inpainted. Bigger values prevent isophotes being inpainted in the wrong direction, but also create more blur. (default: 5.0 Px)


float  sharpness = 30.0
Sharpness describes how faithfull the algorithm follows directional information contained in the structure tensor. Higher values can prevent blurring caused by high Radius values. (default: 30.0)


float  PreBlur = 0.5
PreBlur is the 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. (default: 0.5 Px)


float  PostBlur = 4.0
PostBlur is the standard deviation of the blur which is applied to the structure tensors before they are used to determine the inpainting direction. Higher values help gathering enough directional information when there are only few valid pixels available, but also need lots of CPU cycles. (default: 4.0 Px)


float  ChromaWeight = 0.0
ChromaWeight describes how chroma channels are taken into account when the structure tensor is build. After tensors for each color channel are set up, tensors are added, where luma is weighted with 1.0-ChromaWeight, and all chroma tensors together with ChromaWeight. Tensors not needed are not computed. This parameter is ignored for RGB color spaces: Each channel is weighted equally then. (default: 0.0)


float  PreBlurSize = 2×PreBlur
float  PostBlurSize = 2×PostBlur
PreBlurSize and PostBlurSize describe the sizes of the blurring kernels used for pre blurring and post blurring, respectively. (default: 2×PreBlur and 2×PostBlur, resp.)


bool  ChromaTensor = false
When ChromaTensor is set to true, all structure tensors will be computed again before a chroma channel pixel is inpainted (after the corresponding luma pixel has been inpainted). Chroma values are always inpainted after a luma value has been inpainted in the same position. This can be especially usefull when chroma channels have a lower resultion than luma channels (e.g. YUY2, YV12), i.e. the chroma pixel is not in exactly the same position in which the just inpainted luma pixel is. This argument is ignored for RGB color spaces. (default: false)


float  PixelAspect = 1.0
PixelAspect is the ratio between width and height of a pixel. E.g. for 16:9 DVD movies with a resolution of 720x576, one would use PixelAspect=(16.0/9.0)*(576.0/720.0)≈1.422. This value distorts the circle defined by Radius as well as the blurring kernels and kernel extents and modifies the inpainting order of pixels. (default: 1.0)


int  Steps = -1
If Steps is non-negative, only the first Steps pixels (in the inpainting order which is determined by the distance of the pixels to the border of the inpainting region) are inpainted, all remaining pixels will be untouched. This is mainly usefull for visualizing how the function works and for debugging purposes. If Steps is less then -1, a copyright message will be displayed (along with an error message). (default: -1)


Example

TODO

External Links

  • GitHub - Source code repository.




Back to External Filters

Personal tools