##================================================================================================## # InpaintLoc() manual: # ##================================================================================================## # This function will help you to determine "Loc" values. # string "Loc" : Select a part of picture around the logo. # # Use same as Crop ("Left,Top,-Right,-Bottom") coordinates. # Example: Loc="100,100,-100,-100". # # Or use -ve LogoX,LogoY, and +ve LogoW,LogoH coordinates. # [LogoX=Width-200, LogoY=Height-100, LogoX2=Width-30, LogoY2=Height-20] # Example: Loc="-200,-100,-30,-20". # # Include 10(no less) - ~16 pixel borders around the logo! # The selected area will be highlighted. ##================================================================================================## # InpaintDelogo() manual: # ##================================================================================================## #=========================# # Short basic guide: # #=========================# # ( Things you need before starting InpaintDelogo() ) # # 0) Read help/manual(in 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) Get frames numbers for manual "Analyze" (you can skip it for slower & lower quality job). # 3) Prepare the "mask" manually, or start the function with "Automask=1". # 4) Now you can add this stuff from above to InpaintDelogo() function and run it. # Basic example: /* InpaintDelogo( mask="c:\test\mymask.bmp", \ Automask=0, aMix=0, Loc="100,100,-100,-100", \ Mode="Inpaint", \ Analyze=1, FrB=0, FrW=0, FrS=0) */ #=================# # Parameters: # #=================# # String "Loc" : Use InpaintLoc() function to find coordinates. # Spaces are not allowed in "Loc" parameter. # Use even(mod2) numbers. # Include 10(no less) - ~16 pixel borders around logo! # Black borders shouldn't be present in the "Loc" area. # val "mask" : File based mask: # Full path to the base mask of the logo, a B/W picture (Logo -> white). # Example: mask="C:\mymask.bmp". # Resolution of the image must be same as video clip's frame. # Don't include surrounding bleed of the logo, just exact logo. # Actually script is not strict about a format of the picture, it will # convert whatever you give to a Black/White mask. # You can use "Automask" option to auto-generate the base mask. # # Clip based mask: # "mask" accepts clip input, resolution must be same as "Loc" area. # Dynamic mask expected to be full range Y8 or will be converted. # Static mask must be one frame clip otherwise it will be treated as a dynamic mask. # Int "Automask" : It's like a different function when On, just generates the base mask # of the logo, then you need to turn it off. # "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 # the base mask will be generated. # Will re-analyze on every script load. Best & fast results are with "Analyze" method "3". # In most cases "Analyze" method "4" will be good, and it's fastest to setup. # # 0 - Off (default). # 1 - On. Generates the base mask. Script doesn't do anything else when "On"! # Int "aMix" : Parameter is only for "Automask=1" (from -5 to 5; default: 0). # Lower values = "thinner" mask, higher = "thicker" mask. # Adjust it to generate precise mask of the logo, sometimes it's not possible # then create a mask manually with Photoshop ect.. # No need to include the surrounding bleed of the logo. # Int "Inflate" : Inflates the base mask. # # 0 - Disabled. # 1 - Inflate by 1 pixel (default). # 2 - Inflate by 2 pixels. # String "Mode" : Delogo mode (default: Inpaint): # Inpaint - Use if logo is opaque/hardly transparent. # Deblend - Use if logo is transparent. # Both - Use if logo is both: a logo has transparent and opaque/hardly transparent parts. # Int "Analyze" : Analyze methods for deblend/transparent logo ("Deblend" & "Both" modes). # It creates Color & Alpha masks for deblending, filename will be unique with # every "Analyze" setting in the filename. # When "Automask=1" it creates the base mask, nothing else. # Do "Analyze" and delogo only on frames with logo present!!! No animations too. # # (Adaptive default: 0 - forced for "Inpaint" mode; 1 - for other modes) # # 0 - "Disabled". Not selectable. # # 1 - Fast auto analysis (3% of all frames). In practice auto analysis doesn't # produce good results as not all the frames are good for analysis. # # 2 - Slow auto analysis (all frames). More is not better... Placebo. # # 3 - Manual analysis. This method is the best. # You need one frame where logo area is in a solid black/dark background and # another one in a solid white/bright background. # These two frames must be set with "FrB" & "FrW" parameters and optional "FrS". # # 4 - Manual analysis. Good (in most cases) for the basemask generation with "Automask". # For delogo it's not good, use only if there is no white/bright frame in video and method "1" is worse. # Use only on white logos, will not deblend colored parts of the logo. # Setup is similar as method "3", just without "FrW" (it will be ignored). # Int "ReAnalyze" : Repeats analysis on every script load. (default: 0) # # 0 - Off. logo analysis is not computed if Color/Alpha masks are present. # 1 - On. Logo analysis is always computed even when C/A masks are present. # Int "Deep" : Multi pass deblending and analyze is activated with this option. # Reduce discoloration artifacts, less logo remnants. # Less transparent logo - bigger effect, sometimes no effect at all. # # 1 - Disabled (1-pass). # 2 - 2-pass. # 3 - 3-pass (default). # 4 - 4-pass. # 5 - 5-pass. # Int "FrB" : Frame number of the black/dark frame for manual "Analyze" (default: 0). # Int "FrW" : Frame number of the white/bright frame for manual "Analyze" (default: 0). # Int "FrS" : Extended sequences of the frames for manual "Analyze" (default: 0). # ( 0 - disabled; 1 - 5 frames; 2 - 10 frames; 3 - 30 frames.) # Sequences starts from "FrB" and "FrW" frames. # More frames = better analysis = better delogo. # Be sure that the logo in the sequences still will be in the same/static solid # dark/bright background. # Int "Interp" : Interpolation amount to reduce remnants/artifacts of the logo after deblend. # Basically, a compromise between deblend artifacts and interpolation artifacts. # Interpolation artifacts are most visible when logo is crossing high contrast areas. # (0 - Disabled. Max - 4). (default: 2). # Int "IntSpd" : Speed of "Interp". # # 1 - Fast (default). # 2 - Slow. Slight increase of quality. # 3 - Very slow. Slight increase of quality. # Int "InterpM" : Manipulation of the "Interp" mask. # (1,2) - Amount of pixels around the inflated base mask affected by "Interp", # helps to hide bleed of the logo, if there is any, higher can decrease quality a bit # of "Interp" for the shapy logos. Basically prevents bleed going into interpolation. # For "Deblend"/"Both" modes. # # (-1) - Interpolates only less trasparent parts of the logo. For "Deblend" mode. # # -1 - Enables a mask controlled by "iTune" parameter. # 0 - Disabled (default). # 1 - Adds 1 pixels to interp mask. # 2 - Adds 2 pixels to interp mask. # Int "iTune" : Creates a mask for "Interp"/"InterpM". (from -4 to 4; default: 0). # Creates mask for less transparent part of the logo. # Useful if logo has different levels of transparency, and you don't need to # interpolate very transparent parts as there will be almost no artifacts after deblend, # instead you can "take" good pixels from a deblended very transparent area to do better # interpolation on a less transparent area. # 0 - doesn't mean that it's disabled, it is just a datum-point. # Higher values -> mask expands into more-transparent areas of the logo. # Int "iTinflate" : Inflates the iTune mask. # # 0 - Disabled (default). # 1 - Inflate by 1 pixel. # 2 - Inflate by 2 pixels. # 3 - Inflate by 3 pixels. # Int "oTune" : Creation of the mask for "Both" mode. (from -4 to 4; default: 0). # Creates mask for opaque/hardly transparent part of the logo. # 0 - doesn't mean that it's disabled, it is just a datum-point. # Higher values -> mask expands into more-transparent areas of the logo. # Int "oTinflate" : Inflates the oTune mask. # # 0 - Disabled (default). # 1 - Inflate by 1 pixel. # 2 - Inflate by 2 pixels. # 3 - Inflate by 3 pixels. #===================# # Dynamic mask: # #===================# # Int "DynMask" : Delogo with a dynamic mask, currently not for "Deblend". # All other "Inpaint" only parameters should work with it too. # (Adaptive default: 0 or 1, depends from "mask".) # # 0 - Off - No dynamic mask. Auto-adaptive. # # 1 - External dynamic mask, defined by "mask". Auto-adaptive. Only for "Inpaint". # # 2 - Auto generation of the dynamic mask, based on brightness. For "Inpaint" & "Both". # Useful only if a dynamic logo is brighter than the rest of the video. # # 3 - Auto generation of the dynamic mask, using ClipBlend. Only for "Inpaint". # Useful when brightness of a logo is similar to the rest of video and non-animated Logo periodically # jumps location, logo must stay at the location for consistent periods of time (set by "Dyn3Seq"). # ClipBlend is controled by "ClpBlend". # This mask generation must be done in a single thread - no MT! Source filter must be frame accurate! # # For fine tuning use "Show=3" mode as in it only steps mentioned below are processed: # Internal succession: Clip > "Loc" > "DynTune" > "ClpBlend" > "DynPostTune" >... # Start looking at the ~last frame with logo in a location before adjusting things in "Show=3", # because at other places a logo mask should/may disappear (down the chain those are merged in). # Read about "Dyn3buffer" and parameters mentioned above! # # 4 - Auto generation of the dynamic mask for subtitles with halo. Only for "Inpaint". # Int "DynInflate" : Inflates the dynamic mask. Last in the chain (before "maskPatch" and "oPP"). # # -1 - Similar as 1 but lil weaker ('both' instead of 'square'). # 0 - Disabled (default). # 1 - Inflate by 1 pixel. # 2 - Inflate by 2 pixels. # 3 - Inflate by 3 pixels. # 4 - Inflate by 4 pixels. # Int "DynTune" : Tunes up a dynamic mask for "DynMask=2/3/4". Binarization threshold. (from 128 to 254; default: 200). # Lower values -> mask expands more into the darker areas of video. # Set highest where logo/subtitle is still visible. # String "maskPatch": Full path to a patch image, a B/W picture in size of a "loc" area. # Patches a dynamic mask with a custom static mask. Applies after "DynInflate". # Int "KillNoise" : Undot, and eliminate up to 2px thick artifacts from the dynamic mask (from -5 to 5; default: 0). # Negative pre-adds expand>inpand to reduce sponginess of a mask. # It's after "KillBlobs" in the chain. # # 0 - Disabled (default). # 1 - Undot (RemoveGrain(2). Affects white and black spaces). # 2 - Two pass Undot. # 3 - Hysteresis (inpand>hysteresis to eliminate up to 2x2 white stray pixels). # 4 - Undot + Hysteresis. # 5 - Two pass Undot + Hysteresis. # Int "KillBlobs" : Removes thicker than logo/subs artifacts (from -7 to 7; default: 0). # Minus sign is to indicate a method. # Two methods: Negative -> mt_inpand>mt_hysteresis, # Positive -> mt_inpand>mt_expand. # Negative method removes blobs completely, but if artifact is touching logo/sub then it will be removed too. # Positive method is safer, but leaves edges of the artifacts. # Inner workings: Thicker logo/subs needs higher setting to make logo disappear, what is left is treated as artifact. # Don't use Negative method if there is no thick halo. # Int "preBlobs" : Reduce sponginess of the mask for "KillBlobs". (from -2 to 2; default: 0). # Doesn't do anything if KillBlobs=0. # Minus sign is to indicate a method. # Two methods: Negative -> mt_expand> mt_inpand> KillBlobs, # Positive -> mt_expand> KillBlobs> mt_inpand (bit more effective). # 'Stronger' and 'more effective' is less safe for Negative "KillBlobs". # Don't use if there is no thick halo. # 0 - Disabled (default). # -1 - 'both' mode. # -2 - 'square' mode (bit stronger). # 1 - 'both' mode. # 2 - 'square' mode (bit stronger). # Int "Extract" : Extracts subtitles to images from a dynamic mask with SubsMask2Img() function (0 - Disabled, 1 - Enabled; default: 0). # Works only with "DynMask" through "Show=4". # When enabled the script will work till extraction is done, so use only after a dynamic mask is all set. # Makes stuff work in one go, but it's much slower, see SubsMask2Img() manual somewhere below! # DynMask=3: # #================# # Int "Dyn3Seq" : Parameter for "DynMask=3". # Sets how many frames the logo is in a location (from 10 to 9999, default: 12). # For subtitles set duration of the shortest subtitle or shorter subs will disappear from the mask. # Int "ClpBlend" : Parameter for "DynMask=3". # Sets how many frames will be blended to help to eliminate non-logo areas. # More frames blended - more chance for non-logo areas to disappear from the mask. # Disabling it disables "DynPostTune" automatically. Must be less than "Dyn3Seq"-1. # For subtiles "Dyn3Seq"-2 should be best. # 0 - Disabled (default), for fine tuning. # Int "DynPostTune" : Parameter for "DynMask=3". # Post-blend binarization threshold. (from 0 to 5; default: 0 or 1) # Higher values -> mask expands more into the brighter areas of video. (1=254, increments by -1) # Safest setting is "1", higher will extend logo mask for few frames back and forth, # and possibly some non-logo areas can appear in a mask, but logo mask will get in a lilbit better shape. # If "ClpBlend" is disabled then this will be disabled automatically too. # 0 - Disabled, for fine tuning. # Int "Dyn3buffer" : Parameter for "DynMask=3". # Ignore this if "ClpBlend" is less than "53". ( https://forum.doom9.org/showthread.php?p=1928621#post1928621 ) # Buffer for internal TrimergageFX(). Disable it for the script previewing or preview will be very slow. # Enable it for encoding or AvS will work very slow, and it must go together # with RequestLinear(rlim=ClpBlend+1,clim=ClpBlend+1) placed after the source filter. # # 0 - Buffer disabled. # 1 - Buffer enabled (default). # Int "RePass" : Parameter for "DynMask=3". # Re-pass temporal+KillNoise routines to reduce artifacts. (from 0 to 2; default: 0). # Useful if "KillBlobs" or "KillNoise" are on. # # 0 - Disabled (default). # 1 - Re-pass once. # 2 - Re-pass twice (bit less artifacts). # DynMask3H>0: # #================# # Int "DynMask3H" : Parameter for "DynMask=3". [Maybe better look at "DynMask=4" method] # If subs has dark full halo then it can be used to remove artifacts. Binarization threshold (from 0 to 128; default: 0 - Disabled). # This mask is used to refine a final "DynMask=3" mask using hysteresis. # Is using "Dyn3Seq"/"ClpBlend" settings (don't change). # As longs as there is a single pixel in a contiguous letter part - mask is good (letters can be partly missing). # Artifacts outside subs area doesn't matter much, usually they won't coincide with "DynMask=3" artifacts. # "RePass" wasn't found useful in the final result (on the short sample). After hysteresis there is non-optional repass. # # Use "Show=6" to finetune it, parameters are chained in sequence as they are in this help (except "ModeSH"). # At this step when "ModeSH=1 & TuneH1=0" - mask is shown pre-construct inverted, actual spatial mask is constructed when "TuneH1" is set. # Set lowest where the subtitle halo masking is visible and clear. # 0 - Disabled (default). # Int "ModeSH" : Parameter for "DynMask3H". # Temporal or spatial halo mask method selector (from 0 to 1; default: 1). # 0 - Temporal halo mask. Cons: Slower, doesn't remove some temporal artifacts. Pros: Unknown. # 1 - Spatial halo mask. Pros: Faster, removes temporal artifacts. Cons: Unknown. # Int "TuneH1" : Parameter for "DynMask3H". # Removes thicker than logo/subs artifacts (from 0 to 7; default: 0 - Disabled). # Thicker logo/subs needs higher setting to make subs disappear, what is left is treated as artifact. # Same as positive "KillBlobs" method. # Increase till text is visible, small part of letter missing is ok. # Int "TuneH2" : Parameter for "DynMask3H". # Pre-diff expands (visibly after diff looks like inpands). (from 0 to 4; default: 0 - Disabled). # Increase to reduce halo remnants from the mask, up to where it doesn't affect letters. # Int "TuneH3" : Parameter for "DynMask3H". # Post-diff inpands. (from 0 to 3; default: 0 - Disabled). # Increase up to where letters doesn't disappear completely. # Int "KillNoiseH" : Parameter for "DynMask3H". # Undot, and eliminate up to 1x2px artifacts from the "DynMask3H" mask. # Wasn't found useful in the final result (on the short sample). # # 0 - Disabled (default). # 1 - Undot (RemoveGrain(2). Affects white and black spaces). # 2 - Two pass Undot. # Int "rePassH" : Parameter for "DynMask3H". # Re-pass/pass temporal+KillNoiseH routines to reduce artifacts in "DynMask3H" mask. (0 - Disabled, 1 - Enabled; default: 0). # Wasn't found useful in the final result (on the short sample). # DynMask=4: # #================# # NOTES: : For subtitles with a dark halo. # You can use "DynMask=2" to finetune "DynTune" if you want to see its pure effect (without "DynMask4H" effect). # Int "DynMask4H" : Parameter for "DynMask=4". # Binarization threshold for the subtitles halo (from 1 to 128; default: 60). # Set lowest where the subtitle halo masking is visible and clear. If too low then some letters can disappear. # Use "Show=6" to finetune it. # Int "DynMaskUp" : Parameter for "DynMask=4". # Only to get a neat upsized subtitles mask on Show=4 output. (from -4 to 4; default: 0). # Resolution is multiplied by parameter (-1/0/1 - Disabled). # Positive: First set everything without this parameter as all filtering is done on a not-upsized mask, which is used to do hysteresis into the upsized mask. # Negative: Does filtering on the upsized mask (experimental, WIP). #==================# # Post-process: # #==================# # Int "dPP" : Blur amount applied to delogoed area to hide artifacts (default: 3). # (0 - Disabled. Max - 8). # Int "dPPm" : Adds smooth borders to the deblend mask, used for "dPP" post-process, # it will blend in a deblended area into the surrounding.(default: 3/adaptive). # # 0 - Disabled. Not selectable. Adaptive. # 1 - 3 smooth pixels added. # 2 - 5 smooth pixels added. # 3 - 7 smooth pixels added. # Int "diPP" : Blur amount applied to Interp/iTune area to hide artifacts (default: 5). # Auto disabled if Interp = 0 or InterpM != -1. # (0 - Disabled. Max - 8). # Int "diPPm" : Adds smooth borders to the iTune mask, used for "diPP" (default: 3). # # 0 - Disabled. # 1 - 3 smooth pixels added. # 2 - 5 smooth pixels added. # 3 - 7 smooth pixels added. # Int "oPP" : Blur amount applied to inpainted(opaque) area to calm it down (default: 5). # (0 - Disabled. Max - 8). # Int "oPPm" : Adds smooth borders to the opaque mask, used for "oPP" post-process, # it will blend in an inpainted area into the surrounding.(default: 3). # Auto-disabled if "oPP"=0. # # 0 - Disabled. # 1 - 3 smooth pixels added. # 2 - 5 smooth pixels added. # 3 - 7 smooth pixels added. # Int "GrainPP" : Adds grain, it will blend in an delogoed area into the noisy surrounding. # Requires GrainFactory3. Use only if there is grain or similar noise in video. # (0 - Disabled. 3 - Max noise). (default: 0) # Int "EdgePP" : Creates the edgemask. Inpaints edges of the base or iTune mask. # Useful on the bigger & hardly transparent logos if deblend left strong # artifacts on the edges of the logo. # It ignores "Inflate"/"iTinflate". # # 0 - Disabled (default). # 1 - Enabled. Fast. # 2 - Enabled. Slow. Slight increase of quality # 3 - Enabled. Very slow. Definitely will decrease speed. # Int "EdgePos" : Position of the edgemask. (default: 0). # # -1 - 1px inwards from the initial position. # 0 - The initial position. # 1 - 1px outwards from the initial position. # Int "EdgeWide" : Wideness of the edgemask (default: 1). # # 0 - 2px wide mask. # 1 - 4px wide mask. #=========================# # Pre-process helpers: # #=========================# # int "Show" : Show some masks and steps of the delogo process in "rSize". # # 0 - Disabled (default). # 1 - Various masks and steps. # 2 - a) Stacked Delogoed + PostProcessed steps (can show "mShow"). # b) With a dynamic mask: # Delogoed + Dynamic mask # PostProcessed + Dynamic PP mask # 3 - Only for "DynMask=3". For fine tuning. Pre TrimergageFX(). No resizing. # 4 - Outputs the DynamicMask (Loc area). No resizing. # 5 - Outputs full sized Dynamic PP mask in Y8. No resizing. # 6 - Outputs the "DynMask3H" & "DynMask4H" mask. For fine tuning. # Int "mShow" : Shows you selected mask. Overlays "black hole" over clip. # Shows in "Show = 2" too. # Dynamic mask (in "Inpaint" mode) should work with 2 and 9. # # 0 - Disabled (default). # # These, overlay on top of the processed clip: # 1 - Opaque mask (actual mask for a inpainting job). # 2 - Opaque PP mask (post-process mask for inpainted area). # 3 - Base mask. # 7 - Interp/iTune mask(not for "Inpaint" mode). # 8 - Edge mask (not for "Inpaint" mode). # # These, overlay on top of the original clip: # 4 - Base mask. # 5 - Deblend PP mask (post-process mask for deblend area). # 6 - oTune Mask (not for "Inpaint" mode). # 9 - Opaque PP mask (post-process mask for inpaint area). # Int "rSize" : Resolution of "Show" & "Automask" output. (Default: 4) # 1 - Min (original resolution) to 9 - Max. #============================# # Parameters for Inpaint: # #============================# # Note : Parameters below are useful only if you prefer speed over quality. # Int "Turbo" : "Inpaint" and "Both" presets for very fast, less "alive", blurred, low quality inpainting. # On - will not try to connect isophotes/inpaint shapes of the surrounding. # Going from 1 to 3 will amplify: obtrusive, less blurred, slower. # # 0 - Off (Default). Slowest. High quality inpainting. # 1 - Fastest. For HD video - "2"/"3" should be more suitable imo. # 2 - Faster. # 3 - Fast. # Int "KillShape" : Reduces sponginess of the base/dynamic mask when preserves dimensions of the shape. # Experimental parameter meant for "Turbo", to make inpainted area less "alive". # Will kill any hole up to 6 pixels in diameter. # Works only in "Inpaint" mode. (Default: 0) # 0 - Off. # 1 - On. # Int "prePP" : Pre blurs Loc area for inpainting algo. (Default: 0) # Experimental parameter meant for "Turbo" when in "Inpaint" mode. # 0 - Off. # 1 - On. #============================================# # Parameters of the Inpainting algorithm: # #============================================# # Note : Default settings combo below is generally balanced, it's not recommended # to change any of them if video is not static. # It's in general a very hard task to find the good parameters combo (combo # involves some settings above too. So there is endless combinations...). # Making one scene to look better, will make another one worse. # What is very good for one frame - very bad temporally on the whole clip. # Float "Radius" : Radius around 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 and increase CPU usage. (default: 8.0) # Float "PreBlur" : 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: 6.5) # Float "PostBlur" : 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. (default: 4.0) # Float "Sharpness" : Describes how faithful the algorithm follows directional information # contained in the structure tensor. Higher values can prevent blurring # caused by high Radius values. # (Default: 45.0) ##================================================================================================## # SubsMask2Img() manual: # ##================================================================================================## # NOTE : The subs detection looks only at the middle of video (10% width x 55% height)! # Clip expected to be full range Y8 or will be converted. # Int "Extract" : This is only InpaintDelogo() parameter!!! # Makes stuff work in one go, but it's much slower that using an intermediate file. # It will pass SubsMask2Img() parameters from InpaintDelogo() func to SubsMask2Img(). # When enabled the script will work till extraction is done, so use only after a dynamic mask is all set. # # Fast way: InpaintDelogo() -> encode the mask to a lossless file -> SubsMask2Img(). # Good lossless x264 settings for a mask: "--preset ultrafast --range pc --cabac -q0". # String "ImgDir" : Path to directory where output images are to be written. MUST be set to existing directory. # Float "CorrTh" : Correlation threshold to detect where subtitles in adjacent frames are the same (from 0.5 to 0.95; default: 0.8). # Used to detect where to split apart non similar subs. # Higher - detection more sensitive to the changes in the frames. # Probably no need to touch it. # Int "SubTune" : Post-blend binarization threshold [subtitle range to a single frame] (from 100 to 254; default: 235). # Max = maximum artifacts reduction, if there are, but parts of the letters can disappear too. # Probably no need to touch it. # Int "SubMinDur" : Minimum subtitle duration threshold in frames (from 1 to 20; default = "Dyn3Seq" or 12). # Stuff from the below ranges won't be extracted. # Int "SubSuspect" : Suspicious subtitle duration threshold in frames (from 0 to 40; default: 0). # Extracted images from the below or equal ranges will have "_" prefix in the filenames. # For fast examination of the extracted images. # Recommended setting: 3 frames lower than FPS of video. # Int "ImgType" : Image type to write ("png" or "tif"; default: "png"). # Int "ImgInflate" : Inflate sub mask by 1 pixel (goes after upsize). (from 0 to 1; default: 0). # Int "ImgInvert" : Invert images. (from 0 to 1; default: 0). # Int "ImgSize" : Upsize images by that multiplier. (from 1 to 4; default: 1). ##================================================================================================## # The simplified pseudo scheme of parameters logic (v1.20): # ##================================================================================================## # InpaintLoc()-->[Loc]-->!loc! # # # [mask]->[Loc]->[Analyze]---(if auto)--->[aMix]->[rSize]->!mask! # | | | # (if Automask=1) (if manual)-------->[FrB]+[FrW]+[FrS] # | # InpaintDelogo()-------->[mask]------>[Loc]->| # | # (if Deblend or Both)<----[Mode]---------->(if Inpaint) # | | # [Inflate] [Turbo] # | | # [Deep] [KillShape] # | | # [ReAnalyze]->(if masks ok)---->| [Inflate] # | | | # (if on) | | # | | | # |<------(if manual)<---[Analyze]--->(if auto)-------->| | # | | | # |-->[FrB]+[FrW]+[FrS]------>------------------------->| | # | | # [iTinflate]<--[iTune]<--[if InterpM=-1]<-| | # | | | # |-------------->[Interp]<------[InterpM] | # | | # [IntSpd] | # | | | # |<-[dPP]<-[dPPm]<---(if Deblend)<-----|---->(if Both)-->| | # | | | | # |<-[diPP]<-[diPPm]<-(if InterpM=-1) [oTune] | # | | | # |<-[dPP]<-[dPPm]<-------(if Both) [oTinflate]->[prePP] # | | | # |-->(if Both)-->| [Sharpness]++[PostBlur]++[PreBlur]++[Radius] # | | | # |<---[oPP]<--[oPPm]<--(if Inpaint) # | # |->(if not Inpaint)->[EdgePP]->[EdgePos]->[EdgeWide] # | | # |<------------------------------------------<--| # | # |------->[GrainPP]----->[Show]-->[rSize]-->[mShow]----->!Delogoed Clip! ##================================================================================================## # Functions with all parameters (for advanced users): # ##================================================================================================## /* InpaintDelogo( mask="c:\test\mymask.bmp", \ Automask=0, aMix=0, Loc="100,100,-100,-100", \ Mode="Inpaint", Analyze=1, FrB=0, FrW=0, FrS=0, \ Inflate=1, Deep=3, ReAnalyze=0, \ Interp=2, IntSpd=1, InterpM=0, iTune=0, iTinflate=0, \ dPP=3, dPPm=3, \ oPP=5, oPPm=3, \ diPP=5, diPPm=3, \ EdgePP=0, EdgePos=0, EdgeWide=1, \ Turbo=0, prePP=0, KillShape=0, oTune=0, oTinflate=0, \ DynMask=0, DynTune=200, DynInflate=0, maskPatch="", \ KillBlobs=0, preBlobs=0, KillNoise=0, rePass=0, \ Dyn3Seq=12, ClpBlend=0, DynPostTune=0, Dyn3buffer=1, \ DynMask3H=0, ModeSH=1, TuneH1=0, TuneH2=0, TuneH3=0, KillNoiseH=0, rePassH=0, \ DynMask4H=60, DynMaskUp=0, \ Extract=0, \ GrainPP=0, \ Sharpness=45, PreBlur=6.5, PostBlur=4.0, Radius=8.0, \ Show=0, mShow=0, rSize=4) SubsMask2Img( ImgDir="", CorrTh=0.8, SubTune=235, SubMinDur=12, SubSuspect=0, ImgType="png", ImgInflate=0, ImgInvert=0, ImgSize=1 ) */ ##================================================================================================## # InpaintDelogo function: # ##================================================================================================## function InpaintDelogo ( clip clp, val "mask", string "Loc", string "Mode", int "Analyze", \ int "FrB", int "FrW", int "FrS", int "Interp", int "InterpM", int "Inflate", \ int "oTune", int "ReAnalyze", int "oPP", int "oPPm", int "dPPm", int "dPP", \ float "Radius", float "Sharpness", float "PreBlur", float"PostBlur", \ int "GrainPP", int "Automask", int "aMix", int "mShow", int "Show", \ int "Deep", int "rSize", int "prePP", int "KillShape", int "Turbo", \ int "iTune", int "iTinflate", int "oTinflate", int "diPPm", int "diPP", \ int "EdgePP", int"EdgePos", int"EdgeWide", int "IntSpd", int"DynMask", \ int "DynTune", int "DynInflate", int "KillNoise", string "maskPatch", \ int "ClpBlend", int "DynPostTune", int "Dyn3Seq", int "Dyn3buffer", \ int "KillBlobs", int "preBlobs", int "rePass", \ int "DynMask3H", int "ModeSH", int "TuneH1", int "TuneH2", int "TuneH3", int "rePassH", int "KillNoiseH", \ int "DynMask4H", int "DynMaskUp", \ int "Extract", String "ImgDir", Float "CorrTh", Int "SubTune", Int "SubMinDur", Int "SubSuspect", String "ImgType", Int "ImgInflate", Int "ImgInvert", Int "ImgSize") { # Load AVSInpaint for non AVS+ # # Error for standalone AVS+ # #==============================# avsplus = false try{avsplus = InternalFunctionExists("autoloadplugins")} catch(dummy){} (avsplus == true) ? nop : LoadCPlugin("AVSInpaint.dll") dll_loaded = true try{dll_loaded = FunctionExists("ImageWriter")} catch(dummy){} Assert(dll_loaded == true, "Load 'ImageSeq.dll' with 'LoadPlugin' or install Avisynth+.") # Defaults # #==========# mask = default (mask , "" ) maskPatch = default (maskPatch , "" ) loc = default (loc , "" ) mode = default (mode , "inpaint") analyze = default (analyze , 1 ) deep = default (deep , 3 ) FrB = default (FrB , 0 ) FrW = default (FrW , 0 ) frs = default (frs , 0 ) interp = default (interp , 2 ) interpm = default (interpm , 0 ) dpp = default (dpp , 3 ) dppm = default (dppm , 3 ) dipp = default (dipp , 5 ) dippm = default (dippm , 3 ) oppm = default (oppm , 3 ) turbo = default (turbo , 0 ) dynmask = default (dynmask , 0 ) dyntune = default (dyntune , 200 ) dyninflate = default (dyninflate , 0 ) grainpp = default (grainpp , 0 ) opp = default (opp , 5 ) killshape = default (killshape , 0 ) killnoise = default (killnoise , 0 ) killblobs = default (killblobs , 0 ) preblobs = default (preblobs , 0 ) repass = default (repass , 0 ) dynmask3h = default (dynmask3h , 0 ) modesh = default (modesh , 1 ) tuneh1 = default (tuneh1 , 0 ) tuneh2 = default (tuneh2 , 0 ) tuneh3 = default (tuneh3 , 0 ) dynmask4h = default (dynmask4h , 60 ) dynmaskup = default (dynmaskup , 0 ) killnoiseh = default (killnoiseh , 0 ) repassh = default (repassh , 0 ) prepp = default (prepp , 0 ) radius = default (radius , 8.0 ) sharpness = default (sharpness ,45.0 ) preblur = default (preblur , 6.5 ) postblur = default (postblur , 4.0 ) show = default (show , 0 ) otune = default (otune , 0 ) itune = default (itune , 0 ) amix = default (amix , 0 ) mshow = default (mshow , 0 ) rsize = default (rsize , 4 ) inflate = default (inflate , 1 ) iTinflate = default (iTinflate , 0 ) oTinflate = default (oTinflate , 0 ) automask = default (automask , 0 ) reanalyze = default (reanalyze , 0 ) edgepp = default (edgepp , 0 ) edgepos = default (edgepos , 0 ) edgewide = default (edgewide , 1 ) intspd = default (intspd , 1 ) Dyn3Seq = default (Dyn3Seq , 12 ) ClpBlend = default (ClpBlend , 0 ) DynPostTune = (ClpBlend == 0) ? default (DynPostTune , 0 ) : \ default (DynPostTune , 1 ) Dyn3buffer = default (Dyn3buffer , 1 ) Extract = Default(Extract , 0) CorrTh = Default(CorrTh , 0.8) SubTune = Default(SubTune , 235) SubMinDur = Default(SubMinDur , Dyn3Seq) SubSuspect = Default(SubSuspect , 0) ImgType = Default(ImgType ,"png") ImgInflate = Default(ImgInflate , 0) ImgInvert = Default(ImgInvert , 0) ImgSize = Default(ImgSize , 1) ImgDir = Default(ImgDir , "") # Terminador de cucarachas # #==========================# bugloc = (loc == "" ) ? true : false bugloc2 = (loc == "100,100,-100,-100" ) ? true : false buganalyze = (analyze < 1 || analyze > 4) ? true : false bugreanalyze= (reanalyze < 0 || reanalyze > 1) ? true : false bugdeep = (deep < 1 || deep > 5) ? true : false bugfrs = (frs < 0 || frs > 3) ? true : false buginterp = (interp < 0 || interp > 4) ? true : false buginterpm = (interpm < -1 || interpm > 2) ? true : false bugdpp = (dpp < 0 || dpp > 8) ? true : false bugdipp = (dipp < 0 || dipp > 8) ? true : false bugopp = (opp < 0 || opp > 8) ? true : false bugprepp = (prepp < 0 || prepp > 1) ? true : false bugdppm = (dppm < 1 || dppm > 3) ? true : false bugdippm = (dippm < 0 || dippm > 3) ? true : false bugoppm = (oppm < 0 || oppm > 3) ? true : false bugdynmask = (dynmask < 0 || dynmask > 4) ? true : false bugdyntune = (dyntune < 128 || dyntune > 254) ? true : false bugdynflate = (dyninflate < -1 || dyninflate > 4) ? true : false buggrainpp = (grainpp < 0 || grainpp > 3) ? true : false buginflate = (inflate < 0 || inflate > 2) ? true : false bugiInflate = (iTinflate < 0 || iTinflate > 3) ? true : false bugoInflate = (oTinflate < 0 || oTinflate > 3) ? true : false bugotune = (otune < -4 || otune > 4) ? true : false bugitune = (itune < -4 || itune > 4) ? true : false bugamix = (amix < -5 || amix > 5) ? true : false bugshow = (show < 0 || show > 6) ? true : false bugmshow = (mshow < 0 || mshow > 9) ? true : false bugrsize = (rsize < 1 || rsize > 9) ? true : false bugautomask = (automask < 0 || automask > 1) ? true : false bugkillshape= (killshape < 0 || killshape > 1) ? true : false bugkillnoise= (killnoise < -5 || killnoise > 5) ? true : false bugkillblobs= (killblobs < -7 || killblobs > 7) ? true : false bugpreblobs = (preblobs < -2 || preblobs > 2) ? true : false bugrepass = (repass < 0 || repass > 2) ? true : false bugdynmask3h= (dynmask3h < 0 || dynmask3h > 128) ? true : false bugmodesh = (modesh < 0 || modesh > 1) ? true : false bugtuneh1 = (tuneh1 < 0 || tuneh1 > 7) ? true : false bugtuneh2 = (tuneh2 < 0 || tuneh2 > 4) ? true : false bugtuneh3 = (tuneh3 < 0 || tuneh3 > 3) ? true : false bugkillnoiseh= (killnoiseh < 0 || killnoiseh > 2) ? true : false bugrepassh = (repassh < 0 || repassh > 1) ? true : false bugdynmask4h= (dynmask4h < 1 || dynmask4h > 128) ? true : false bugdynmaskup= (dynmaskup < -4 || dynmaskup > 4) ? true : false bugturbo = (turbo < 0 || turbo > 3) ? true : false bugedgepp = (edgepp < 0 || edgepp > 3) ? true : false bugedgepos = (edgepos < -1 || edgepos > 1) ? true : false bugedgewide = (edgewide < 0 || edgewide > 1) ? true : false bugintspd = (intspd < 1 || intspd > 3) ? true : false bugmode = (mode != "inpaint" && mode != "deblend" && mode != "both" ) ? true : false bugcombo1 = (mode == "inpaint" && mshow > 4 && mshow < 9) ? true : false bugcombo2 = (mode != "inpaint" && analyze == 3 && FrB == FrW) ? true : false bugcombo3 = (mode != "inpaint" && killshape == 1) ? true : false bugcombo4 = (IsString(mask) && dynmask==0) ? eval(""" bugcombo4 = (mask == "") ? true : false return bugcombo4 """) : false bugcombo5 = (IsString(mask) && dynmask==0) ? eval(""" bugcombo5 = (findstr(mask,":") == 0) ? true : false return bugcombo5 """) : false bugcombo6 = (ClpBlend == 0 && show != 3 && dynmask == 3 || DynPostTune == 0 && show != 3 && dynmask == 3) ? true : false bugcombo7 = (mode == "inpaint" && edgePP != 0 ) ? true : false bugcombo8 = (dynmask != 3 && repass != 0 ) ? true : false bugcombo9 = (dynmask3h == 0 && dynmask != 4 && show == 6) ? true : false bugcombo10 = (dynmask3h != 0 && dynmask != 3 ) ? true : false bugcombo11 = (Extract == 1 && show != 4 ) ? true : false bugDyn3Seq = (Dyn3Seq < 10 || Dyn3Seq > 9999) ? true : false bugClpBlend = (ClpBlend < 8 || ClpBlend >= Dyn3Seq-1) ? true : false bugDynPostTune = (DynPostTune < 0 || DynPostTune > 5) ? true : false bugDyn3buffer = (Dyn3buffer < 0 || Dyn3buffer > 1) ? true : false assert ( findstr(loc," ") == 0 , """Space character is not allowed in string "Loc".""") assert ( IsString(mask) || IsClip(mask), """"mask" only accepts string/path or clip input.""") assert ( bugcombo4 == false , """You have to define the "mask" string""") assert ( bugcombo5 == false , "Specify full path to the logo mask!") assert ( bugcombo6 == false , """There is nothing to do with these settings, fine tune this mask in "Show=3".""") assert ( bugloc == false , """You must define "Loc".""") assert ( bugloc2 == false , """Use "InpaintLoc" function to get crop values for "Loc".""") assert ( bugmode == false , """This mode doesn't exist. Change "Mode" value.""") assert ( bugcombo1 == false , "Calculating the meaning of life and everything. Meanwhile RTM.") assert ( bugcombo2 == false , "Calculating the meaning of life and everything. Meanwhile RTM.") assert ( bugcombo3 == false , """"KillShape" parameter is only for "Inpaint" mode.""") assert ( bugcombo7 == false , """"EdgePP" parameter is not for "Inpaint" mode.""") assert ( bugcombo8 == false , """"RePass" parameter is only for "DynMask=3" method.""") assert ( bugcombo9 == false , """"Show=6" parameter is only for "DynMask3H" & "DynMask=4" mask.""") assert ( bugcombo10 == false , """"DynMask3H" parameter is only for "DynMask=3" method.""") assert ( bugcombo11 == false , """Subtitles extraction works only with "Show=4" parameter.""") assert ( buganalyze == false , """"Analyze" value must be between 1 and 4.""") assert ( bugreanalyze == false , """"ReAnalyze" value must be between 0 and 1.""") assert ( bugdeep == false , """"Deep" value must be between 1 and 5.""") assert ( bugfrs == false , """"FrS" value must be between 0 and 3.""") assert ( buginterp == false , """"Interp" value must be between 0 and 4.""") assert ( buginterpm == false , """"InterpM" value must be between -1 and 2.""") assert ( bugdpp == false , """"dPP" value must be between 0 and 8.""") assert ( bugdipp == false , """"diPP" value must be between 0 and 8.""") assert ( bugopp == false , """"oPP" value must be between 0 and 8.""") assert ( bugprepp == false , """"prePP" value must be between 0 and 1.""") assert ( bugdppm == false , """"dPPm" value must be between 1 and 3.""") assert ( bugdippm == false , """"diPPm" value must be between 0 and 3.""") assert ( bugoppm == false , """"oPPm" value must be between 0 and 3.""") assert ( bugdynmask == false , """"DynMask" value must be between 0 and 4.""") assert ( bugdyntune == false , """"DynTune" value must be between 128 and 254.""") assert ( bugdynflate == false , """"DynInflate" value must be between -1 and 4.""") assert ( buggrainpp == false , """"GrainPP" value must be between 0 and 3.""") ass