VideoHelp Forum
+ Reply to Thread
Results 1 to 1 of 1
Thread
  1. Member
    Join Date
    Aug 2007
    Location
    Isle of Man
    Search Comp PM
    Hi All,

    I'm setting up a repair for a clip damaged by lens blur (http://www.mediafire.com/file/0lym5r657vplaa7/Wide-angle_lens_blurring_sample.wmv). There's gradated centre-to-edge blur throughout, but there are also random "wash-outs" from luma flares which vary from frame to frame. This made a simple centre-to-edge gradated circular repair mask suboptimal, so I came up with this way of doing adaptive lens blur masking:

    Code:
    # TODO: wrap in function and parameterise
    
    a = last
    
    # Remove grain before generating mask and sharpening
    a = a.TemporalDegrain (degrain=3, SAD2=400)
    
    # Create frame-adaptive mask
    #
    # TODO: evaluate other approaches (e.g. try to directly identify luma flares)
    #
    # Identify detailed vs flat areas (luma only)
    thY1 = 22
    thY2 = 34
    a.mt_edge(mode="hprewitt", thY1=thY1, thY2=thY2, y=3, u=-128, v=-128)
    # Consolidate detailed and flat areas
    medianblur(50,0,0)
    # Normalise mask levels to around full range to prevent sharp transitions around mask edges
    Levels(max(0, thY1-1), 1.000, min(255, (thY2+1)), 0, 255, coring=false)
    # Smoothen mask banding
    Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58) \
    .Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58).Blur(1.58)
    ALBMask = Invert(channels="Y")
    
    # Create repaired clip
    #
    # TODO: complete evaluation of sharpeners
    strength = 1.0
    # Purposely try to "repair" colour component too
    blr=gaussianblur(a,varY=128,varC=128,border=4,integrate=true,Y=3,U=3,V=3)
    mt_lutxy(blr,a,"y x - "+string(strength)+" * y +",y=3,u=3,v=3)
    
    # Normalise levels somewhat after including colour component above
    
    repaired = Tweak(hue=0.0, sat=0.7, bright=25.0, cont=0.8)
    
    # TODO: add motion compensation to temporally smooth repair artifacts
    
    # TODO: add optional soft sharpening of original (doesn't add value with current footage)
    
    mt_merge (a, repaired, ALBMask, luma=false, y=3, u=3, v=3)
    Results so far are very encouraging, but there are some issues I would very much appreciate your suggestions and guidance on.

    1. The two blurring steps above are quite crude - are there better ways of doing those?

    2. Using edge detection to infer blur leads to over-repairing of areas that really don't contain detail. Fortunately this clip has enough detail and doesn't have that problem, but in principle the following alternative to identifying luma flares sounds possible:

    Code:
    Create a rough mask, e.g. with edge detection as above
    Within that mask area, look for the characteristics of these luma flares:
    areas of above-threshold luma with above-threshold contrast to adjacent areas
    Use the edge detection mask for general sharpening as above (perhaps a bit weaker) Repair areas within the luma flare mask more aggressively:
    perhaps topological reconstruction and stronger sharpening, normalising their luma and contrast closer to adjacent areas etc. Or perhaps even try to replace pixels with unaffected ones from other frames.
    Does it sound possible to do this in a script? If so, in principle, which tools would you suggest for the various steps?

    3. Do you know of existing frame-adaptive masking scripts I can look at? Especially ones that look for luma flares?

    4. Ditto for scripts that look for healthy replacement pixels in other frames and intelligently handle cases where not all affected pixels could be replaced?

    5. Am I going the right direction, barking up the wrong tree, anything else?

    Many thanks in advance,
    Francois
    Last edited by fvisagie; 12th Nov 2012 at 07:53. Reason: Fixed .blur().blur()... copy and paste
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!