VideoHelp Forum

Our website is made possible by displaying online advertisements to our visitors.
Please consider supporting us by disabling your ad blocker or buy PlayOn and record Netflix! :)
+ Reply to Thread
Results 1 to 14 of 14
  1. I have a film that suffers from light leakage, so there is a large spot on the side that is brighter than the rest of the frame. This bright area is consistent throughout the entire film. I can fix this sort of thing in Photoshop for a still image, using a gradient mask corresponding to the light area to be corrected, and correct using a darkening layer.

    How can I do a similar thing using AVISynth? I can create a gradient mask, in either black on white, or white on black. Can I use some function in AVISynth to darken this area, blend, or what do you suggest?
    Quote Quote  
  2. Oe way to do it would be to use overlay() using the gradient mask; white areas are "transparent" . You might not need to use blend modes depending on the defect, but you can experiment with them

    To darken the area, you can use levels() or smoothlevels() and adjust the gamma . Levels takes the same arguments as photoshop levels

    So you would have 2 clips , the original with defect, the mask, and a dark version of the video . The white areas of the mask delineate where the dark version "pokes through" to cover up the original video

    You could do the same thing with masktools and mt_merge as well
    Quote Quote  
  3. Use an alpha mask and a black frame with the Logo filter.
    Quote Quote  
  4. I ended up using the overlay function of AVISynth and it worked great, but I could not find much logic to the modes like add, blend, darken, etc. I ended up using softlight, which gave a nice blended result. Thanks for the help!
    Last edited by kinglerch; 9th Apr 2012 at 07:58.
    Quote Quote  
  5. I have a similar problem on a new film. In this case, the left side of the film is brighter than the right side.

    So I created a gradient BMP in photoshop and then used the Overlay function in AVISynth. The result was what I wanted (darkening on the left) the problem is that the result had very wide banding, which was weird because the gradient from photoshop seemed very clean to me. Am I running into a problem with the Overlay function, unable to see all the levels of grey? Or is there another way to do what I am trying to do? Maybe another tool would do a better job with the many levels of grey?
    Quote Quote  
  6. Post your script. Some sample images too. I seem to recall Overlay() does have some problems. Are you working in RGB or YUV? You could also try using mt_merge() from MaskTools.
    Last edited by jagabo; 9th Apr 2012 at 08:13.
    Quote Quote  
  7. My source is here, should be YUV

    one = AVISource("e:\input.avi")
    two = ImageSource("black.bmp")
    mask1 = ImageSource("black2.bmp")
    overlay(one, two, x=0, y=0, mode="darken", mask=mask1, opacity=.5)

    black.bmp is a totally black 1920x1080 square. black2.bmp is my gradient:

    Quote Quote  
  8. "Banding" is "normal" in legal range 8-bit YUV ; White to black is expressed from 16-235 so there are fewer "slots" for expression from a white to black gradient . In full range YUV, values range from 0-255 just like RGB

    Your bmp is RGB, but your video source is probably legal range YUV (16-235)

    Either convert the RGB bmp to YUV using ConvertToYV12(matrix="PC.709"), or maybe you fiddle with "pc_range=true" for Overlay (internally, I think overlay works in YUY2), but you may have to adjust your gradient
    Quote Quote  
  9. Even in full range RGB and YUV banding is normal. 8 bit color simply isn't enough to eliminate banding in smooth gradients. Using AddGrain() to add noise to the gradient will help.
    Quote Quote  
  10. Is there a function to create a fullrange gradient, similar to maybe mt_edge so I don't have to deal with a bitmap at all? Just something to make a gradual brightness reduction, from left to right?
    Quote Quote  
  11. Originally Posted by kinglerch View Post
    Is there a function to create a fullrange gradient
    Use your current gradient bitmap and ConvertToYV12(matrix="PC.601"). But that won't help very much.

    Try the attached images and scripts. You'll see that working in RGB and YUV you get similar banding.
    Image Attached Files
    Quote Quote  
  12. To verify the problems isn't limited to Overlay() I did a similar adjustment with mt_merge() (and the above images):

    dark=ColorYUV(src, gain_y=-113, cont_u=-113, cont_v=-113)
    mt_merge(src, dark, grad, true)
    Quote Quote  
  13. Using full range won't necessarily help because you're probably going back to limited range YUV. Full range only helps if you keep full range all the way. (i.e when viewing, the YUV => back to RGB conversion is done with full range as well)

    As jagabo mentioned, you can improve 8-bit banding by dithering it, just add gradfun3() from the dither package

    Dithering is just a form of fine noise, but it's a lot more pleasant than adding coarse noise. gradfun3() uses ordered dithering, which is less bitrate intensive to encode

    I took jagabo's "yuv.avs" example and used .

    You can also work in "fake" 16-bit with avisynth, then dither back to 8-bit, there are several ways to do this, but I find the benefits are minimal. The main problem is 8-bit "legal" range video

    You can compare the screenshots attached
    Image Attached Files
    Quote Quote  
  14. Member
    Join Date
    Jul 2009
    Search Comp PM
    Originally Posted by kinglerch View Post
    Is there a function to create a fullrange gradient, similar to maybe mt_edge so I don't have to deal with a bitmap at all? Just something to make a gradual brightness reduction, from left to right?
    Using MaskTools:
    mt_lutspa(expr="x 255 *")

    It doesn't help with banding of course, just a way to generate the mask from scratch without using a bitmap.
    And by varying the 'expression', you can use the same function to generate all sorts of masks.
    Quote Quote  

Similar Threads