VideoHelp Forum

Try DVDFab and download streaming video, copy, convert or make Blu-rays,DVDs! Download free trial !
+ Reply to Thread
Results 1 to 6 of 6
  1. Hello. I am prefiltering animated content with McTemporalDenoise, but I only want to denoise light pixels, and mask dark ones. Now, I've tried using a binarize mask (mt_binarize) which works okay, but leads to other issues in my final result (as I am doing a second pass with Smdegrain to tackle the dark pixels, since it treats them much better).

    However, after reading further into the MCTemporalDenoise functions, I discovered that there is a function called "bias", which allows you accomplish the masking task with dark/light pixels.

    But I'd like to actually see what I'm masking/filtering. I'd like to run a test script using a color so that I can see this. Can someone offer such a script?

    However, I also know that Mc uses MVTools, so I don't even know if I can accomplish what I'm trying to with just Mc

    Quote Quote  
  2. Everyone must be on vacation.
    Quote Quote  
  3. I don't really know what the bias function does but it is very subtle. If you really want to control the denoising by brightness build you own mask and overlay the denoised video over the original video via the mask.

    For example,

    function YMask(clip v, int min, int max)
        Levels(v, min, 1, max, 0, 255, coring=false).GreyScale()
    Will build a mask based on the Y channel. Y values below min become 0, Y values above max become 255, Y values in between are proportionally spaced between those extremes. For example, a greyscale ramp:

    [Attachment 49727 - Click to enlarge]

    after YMask(min=100, max=156)


    [Attachment 49728 - Click to enlarge]

    Now you know how to build a mask based on intensity.

    When you use a mask with Overlay() the pixels where the mask is black are taken from the first video, the pixels where the mask is white are taken from the second video. The pixels where the mask is in between are a weighted average of the two videos.

    original = WhateverSource(...)
    mymask = original.YMask(100,156) # adjust to suit your video
    denoised = original.MCTemporalDenoise()
    Overlay(original, denoise, mask=mymask)
    If you want to easily see the differences Interleave() the original and the new image. Add to the end of the script:

    Interleave(original, last)
    Then flip back and forth between frames in an editor (left, right arrows in VirtualDub, for example). If you want a more obvious hint add the mask to the interleave:

    Interleave(original, last, mymask)
    Quote Quote  
  4. Interesting, thanks Jagabo. After some trial and error, I settled for mt_binary, which masks out the black pixels (part of what I wish to achieve), while allowing me to filter other colors and gradients. In order to adjust, I'm using ColorYUV(gain_y=, off_y=, cont_y=). As I play around with it, I'm finding it much easier to manipulate what I want to filter, and what I want to leave alone.

    So my script looks something like this:

    b=blankclip(a, color=color_orange) ##color for testing only so that I can see what will be masked and what will be filtered
    mask = mt_binarize(threshold=70, ColorYUV(gain_y=50, off_y=-40, cont_y=30). Blur(1.5). toon(). Fastlinedarkenmod(). toon(). toon(). toon(). Santiag())
    Now here's my question: My video is a YV12() source, so I'm wondering if temporarily converting it to RGB32 and, instead of adjusting my masks using ColorYUV, I can do a much better job with AdjustRGBLevels().

    Then when I'm done, I can convert back to YV12.

    Will it make a difference?
    Quote Quote  
  5. Also of course, if you see any adjustments I can make here, please let me know.

    Quote Quote  
  6. YMask() returns the same mask as mt_binarize() if you set min and max to the same threshold as mt_binarize(). So YMask(min=70, max=70) returns the same mask as mt_binarize(threshold=70). Though YMask() also forces the output to greyscale. I usually prefer to use softer edges so that you don't get an obvious demarcation where the mask stops. For example a yellow ramp:

    [Attachment 49768 - Click to enlarge]

    mask = YMask(120,120)
    Overlay(last, Tweak(hue=10), mask=mask)
    [Attachment 49769 - Click to enlarge]

    mask = YMask(100,140)
    Overlay(last, Tweak(hue=10), mask=mask)
    [Attachment 49770 - Click to enlarge]

    Yes, some color adjustments can only be made (or are much more easily made) in RGB. So sometimes you cannot avoid converting to RGB. You will get a little blurring of colors with a round trip from YV12 to RGB to YV12.

    Be sure your levels are correct before the conversion so you don't lose superblacks and superwhites.
    Quote Quote  

Similar Threads