VideoHelp Forum
+ Reply to Thread
Results 1 to 23 of 23
Thread
  1. I was working on a DVD of mine and I noticed a horizontal white line that goes all the way across the bottom. Some scenes its hard to see, others its very annoying to me and very obvious such as on white areas. Its always in the same place and through the entire movie.

    This is a progressive source, so its not being created with IVTC.

    I suppose I could simply just crop it off by cropping 2 from the bottom, but I wish to keep the video in it if possible.

    Is there any way to remove these?

    https://forum.videohelp.com/images/imgfiles/E5ypqLG.png

    https://forum.videohelp.com/images/imgfiles/DCKd9bM.png (Zoomed in for easier visibility)


    I tried 2 halo removers and it did not get rid of it, just reduced its visibility some at the expense of blurring the video/details a bit. I, in the end was hoping to avoid that.

    I noticed really strong denoising like deen() will remove it, but that destroys so much detail.

    Anyone have any better alternatives to this?

    Is it possible to filter only the bottom 2 horizontal rows of pixels with denoise instead of the entire thing?
    Last edited by killerteengohan; 7th Mar 2018 at 10:16.
    Quote Quote  
  2. Originally Posted by killerteengohan View Post
    Is it possible to filter only the bottom 2 horizontal rows of pixels with denoise instead of the entire thing?
    Just use Overlay() with a mask.
    Quote Quote  
  3. Thanks for the idea. I have zero experience using overlay and have never done it before.

    Would you mind giving me an example of its usage in the script if I wanted to mask or protect everything but the bottom 2 rows of pixels?
    Quote Quote  
  4. Something like this:

    Code:
    source=Mpeg2Source("filename.d2v")
    filtered = source.Deen(...) # or whatever
    
    # construct a mask that's black except for two lines at the bottom that are white
    black = BlankClip(width=source.width, height=source.height-2, color=COLOR_BLACK)
    white = BlankClip(width=source.width, height=2, color=COLOR_WHITE)
    mask = StackVertical(black,white).ConvertToYV12(matrix="PC.601")
    
    Overlay(source, filtered, mask=mask)
    Quote Quote  
  5. Originally Posted by jagabo View Post
    # construct a mask that's black except for two lines at the bottom that are white
    black = BlankClip(width=source.width, height=source.height-2, color=COLOR_BLACK)
    white = BlankClip(width=source.width, height=2, color=COLOR_WHITE)
    mask = StackVertical(black,white).ConvertToYV12(matrix="P C.601")
    I can use that. It'll save me trying to draw straight white and black lines in a photo editor. Thanks a lot!
    Quote Quote  
  6. Yes, I often construct mask like that. If I need a fuzzy boundary I'll Blur() or BilinearResize() down and back up.
    Quote Quote  
  7. Member nicksson's Avatar
    Join Date
    Apr 2005
    Location
    Hungary
    Search Comp PM
    Jagabo, and what if the blank line(s) is located at the top of the clip, not at bottom? How to set the height in your script?
    Quote Quote  
  8. Originally Posted by jagabo View Post
    Yes, I often construct mask like that. If I need a fuzzy boundary I'll Blur() or BilinearResize() down and back up.
    Another good idea. But the photo editor has nice blur filters to handle that. It's just drawing those straight lines that drives me nuts. And then maybe having to redo it if it's too thin or fat. It takes tons of time and your method is way fast and easy.

    Jagabo, and what if the blank line(s) is located at the top of the clip, not at bottom? How to set the height in your script?
    Just reverse the black and white in the StackVertical line:

    mask = StackVertical(white,black).ConvertToYV12(matrix="P C.601")

    The first one is the top one.
    Quote Quote  
  9. Thanks for the example. I will play around and adjust it to learn more about it until I fully get the hang of it's usage.

    Is this how the mask works?

    black = untouched or protected pixels on the video
    and
    white= filtered pixels that are placed over top of the video?

    is it ever the opposite? I'm not sure if the colors are 100% certain or if you just chose those 2 colors at random.


    and lastly, should I add this to the bottom of my finished script after all the filtering I want is done, or up near the top of it?
    Last edited by killerteengohan; 8th Mar 2018 at 05:12.
    Quote Quote  
  10. Overlay creates a new video from two source videos. Without a mask the second image is just laid on top of the first (think picture-in-picture). When using a mask, the output is taken from the first video where the mask is black, from the second where the mask is white. For shades of grey in between it is a weighted average of the two sources.

    Add the sequence wherever it makes sense in your script.
    Quote Quote  
  11. Originally Posted by nicksson View Post
    Jagabo, and what if the blank line(s) is located at the top of the clip, not at bottom?
    Read the StackVertical section of the AviSynth docs.

    Originally Posted by nicksson View Post
    How to set the height in your script?
    Read the BlankClip section of the AviSynth docs.

    Both those changes are trivial.
    Quote Quote  
  12. Originally Posted by jagabo View Post
    Overlay creates a new video from two source videos. Without a mask the second image is just laid on top of the first (think picture-in-picture). When using a mask, the output is taken from the first video where the mask is black, from the second where the mask is white. For shades of grey in between it is a weighted average of the two sources.
    That makes much more sense after reading that statement. Also makes my figuring out it even easier when I go to play around with parameters. Thanks!!

    Is the .ConvertToYV12(matrix="PC.601") necessary? I thought DVD was already Rec.601.
    Quote Quote  
  13. The conversion to YV12 isn't strictly necessary. Overlay can use an RGB mask (BlankClip produces RGB by default), even when overlaying YUV videos. But I often like to see the mask when I'm tuning a script (sometimes the mask is based on edges, brightness, colors, or other properites of the source video). I'll use a sequence like: Interleave(original, modified, mask) to view the original video, the modified video with the overlay, and the mask. Since the sources are YV12 the mask must also be YV12 to interleave it. ConvertToYV12() uses a rec.601 matrix by default. That puts blacks at Y=16, and whites at Y=235. But Overlay uses the full 0-255 range for the mask. So the PC.601 matrix is used instead, putting blacks at 0, whites at 255.
    Quote Quote  
  14. Will this work with vertical rows of pixels as well? I have tried changing the widths but I always get a script error. Usually something about image widths don't match


    Code:
    source=Mpeg2Source("filename.d2v")
    filtered = source.Deen(...) # or whatever
    
    # construct a mask that's black except for two lines at the bottom that are white
    black = BlankClip(width=source.width-2, height=source.height-2, color=COLOR_BLACK)
    white = BlankClip(width=2, height=2, color=COLOR_WHITE)
    mask = StackVertical(black,white).ConvertToYV12(matrix="PC.601")
    
    Overlay(source, filtered, mask=mask)

    What am I doing wrong and how would I adjust it if I wanted to say only filter the left 2 rows of vertical pixels?
    Quote Quote  
  15. Originally Posted by killerteengohan View Post
    Will this work with vertical rows of pixels as well? I have tried changing the widths but I always get a script error. Usually something about image widths don't match


    Code:
    source=Mpeg2Source("filename.d2v")
    filtered = source.Deen(...) # or whatever
    
    # construct a mask that's black except for two lines at the bottom that are white
    black = BlankClip(width=source.width-2, height=source.height-2, color=COLOR_BLACK)
    white = BlankClip(width=2, height=2, color=COLOR_WHITE)
    mask = StackVertical(black,white).ConvertToYV12(matrix="PC.601")
    
    Overlay(source, filtered, mask=mask)

    What am I doing wrong and how would I adjust it if I wanted to say only filter the left 2 rows of vertical pixels?
    stackhorizontal, because you want white strip on the left, black on the right . You're not adjusting height this time, so it should be source.height
    Code:
    # construct a mask that's black except for two lines at the LEFT that are white
    black = BlankClip(width=source.width-2, height=source.height, color=COLOR_BLACK)
    white = BlankClip(width=2, height=source.height, color=COLOR_WHITE)
    mask = StackHorizontal(white,black).ConvertToYV12(matrix="PC.601")
    If you're ever in doubt, view the mask alone
    Quote Quote  
  16. Thanks for all the help, this helped me quite a bit and its appreciated.
    Quote Quote  
  17. Would you mind helping me with this overlay mask once more please.

    What if I want to filter every pixel except the very top and bottom 2 rows of pixels. So only the top 2 horizontal rows and bottom 2 horizontal rows are being unfiltered?

    Those earlier ones showed me how to filter just the the top, bottom, left, or right rows of pixels one at a time. How would I set the mask up if I wanted to do 2 at a time? Say protecting top and bottom.

    This time I am wanting them be unfiltered, not filter them. And I want to do 2 sides instead of just one.

    Imagine cropping 2 from the top and bottom for a total of 4, then filtering everything, then putting the 4 back on unfiltered. Does what I want make sense?
    Quote Quote  
  18. Originally Posted by killerteengohan View Post
    Would you mind helping me with this overlay mask once more please.

    What if I want to filter every pixel except the very top and bottom 2 rows of pixels. So only the top 2 horizontal rows and bottom 2 horizontal rows are being unfiltered?

    Those earlier ones showed me how to filter just the the top, bottom, left, or right rows of pixels one at a time. How would I set the mask up if I wanted to do 2 at a time? Say protecting top and bottom.

    This time I am wanting them be unfiltered, not filter them. And I want to do 2 sides instead of just one.

    Imagine cropping 2 from the top and bottom for a total of 4, then filtering everything, then putting the 4 back on unfiltered. Does what I want make sense?


    So do exactly what you imagined in the last sentence. Crop 2 from top, 2 from bottom on a "white" clip the same characteristics as the 'source'. Add "black" borders back that you just cropped

    Code:
    mask=blankclip(source, color=color_white).crop(0,2,0,-2).addborders(0,2,0,2)
    Quote Quote  
  19. actually that's a limited range mask . In YUV when using blankclip, addborders, the "white" is at 235 and "black" is at 16. This means the "black" areas will still be affected and the "white" areas will not quite be 100% affected


    To make it full range (0-255) in Y , add coloryuv(levels="tv->pc")

    Code:
    mask=blankclip(source, color=color_white).crop(0,2,0,-2).addborders(0,2,0,2).coloryuv(levels="tv->pc")



    Or another way is to filter it, crop and add back the unfiltered borders with stackvertical (ie. don't even use masks or overlay)
    Last edited by poisondeathray; 22nd Mar 2018 at 23:40.
    Quote Quote  
  20. Originally Posted by poisondeathray View Post
    Or another way is to filter it, crop and add back the unfiltered borders with stackvertical (ie. don't even use masks or overlay)
    Don't they have to be the same height and width for stackvertical to work? How would I crop them off then add this cropped and filtered image over the original?
    Quote Quote  
  21. Originally Posted by killerteengohan View Post
    How would I set the mask up if I wanted to do 2 at a time? Say protecting top and bottom.

    This time I am wanting them be unfiltered, not filter them. And I want to do 2 sides instead of just one.

    Imagine cropping 2 from the top and bottom for a total of 4, then filtering everything, then putting the 4 back on unfiltered.
    You don't even need masks for this:

    Code:
    source = WhateverSource() # get the source
    filtered = source.Crop(0,2,-0,-2).Filters() # cut two lines off the top and bottom, then filter
    Overlay(source, filtered, x=0, y=2) # overlay the filtered image onto the source
    Last edited by jagabo; 23rd Mar 2018 at 06:50.
    Quote Quote  
  22. Or, somewhat more inefficiently (but maybe more intuitively):

    A=Last
    B=Filter of choice
    B=B.Crop(0,2,0,-2)
    Overlay(A,B,0,2)


    That's how I do it a lot.
    Quote Quote  
  23. Yes, there are many ways to do it.

    But I remember someone (?gavino) saying there is more overhead with overlay() . It's going to depend on the specific script, filters and bottlenecks, but if you can crop and stack, most of the time it will be faster than overlay . Same with scripts that are able to use mt_merge() instead of overlay() - mt_merge is preferred for speed




    A quick test with dvd , and deen() the filter he was using, it's about 20-22% faster in avsmeter. But that only translates to about 6-7% faster actual encoding speed (tested with x264).

    The faster the "filter", the larger the difference. For example levels(0,1.2,255,0,255,false) with a gamma shift is about 50% faster in avsmeter

    (This was with x86, vanilla avisynth observations)

    overlay
    Code:
    a=MPEG2Source()
    b=a.deen().crop(0,2,0,-2,true)
    
    overlay(a,b,0,2)
    crop , stack
    Code:
    a=MPEG2Source()
    b=a.deen().crop(0,2,0,-2,true)
    
    stackvertical(stackvertical(a.crop(0,0,0,-478) , b) , a.crop(0,478,0,0,true))
    Quote Quote  



Similar Threads

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