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. |
25th January 2015, 20:46 | #1 | Link |
Registered User
Join Date: Apr 2008
Location: California, USA
Posts: 127
|
HotSpot Suppressor - need speed up suggestions
I wrote a script to suppress intermittent hot spots (e.g. flashing lights in front of a dashcam). The function gradually blends increasing lumen shifts as pixel values approach pure white, but is painfully slow due to the looped Levels commands used to swap each target luminosity value for another. An uncompressed test file is available HERE.
Can anyone suggest a faster method or -hopefully- convert it to a plug-in that is AviSynth 2.58 (and optionally 2.6) compatible? I appreciate any assistance. Code:
### function HotSpotSuppressor() ### ### v1.0 by "Forensic" 24 Jan 2015 ### ### Needed filter : Gscript ### function HotSpotSuppressor(clip clip, int "loop", int "strength", float "opacity") { loop = default(loop,20) strength = default(strength,5) opacity = default(opacity,.2) Assert(loop >=1 && loop <=40 ? true : false, chr(10) + "Loop variable must be a positive integer from 1 to 40" + chr(10)) Assert(strength >=1 && strength <=10 ? true : false, chr(10) + "Strength variable must be a positive integer from 1 to 10" + chr(10)) Assert(opacity >=.1 && opacity <=.9 ? true : false, chr(10) + "Opacity variable must be a positive number from .1 to .9" + chr(10)) GScript(""" a = clip mask = a.greyscale.bicubicresize( int( a.width/16 )*4, int( a.height/16 )*4 ).bicubicresize( a.width, a.height ) #resize to ignore salt noise for( b=0,loop,1 ) { oldLumen = 255-loop+b newValue = max( 0,255-strength*b ) #used for the newLumen value and also the gamma shift mask = mask.levels( oldLumen, newValue, 0, newValue, 255 ) blend = a.Overlay( a.Overlay( mask, mode = "subtract" ), mode = "subtract" ) clip = clip.Overlay( blend, mode = "blend", opacity=opacity ) } return (clip) """)} Last edited by Forensic; 25th January 2015 at 22:01. |
26th January 2015, 07:53 | #4 | Link |
Registered User
Join Date: Apr 2008
Location: California, USA
Posts: 127
|
Never mind. I came up with a simple effective solution.
Code:
function HotSpotSuppressor (clip clip) { return (clip.overlay(clip.greyscale.bicubicresize(48,48).bicubicresize(clip.width,clip.height).levels(128,.5,255,254,255,coring=false).levels(254,128,255,0,64,coring=false),mode="subtract")) } |
Tags |
hotspot, levels, opacity, plug-in, script |
|
|