This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Deoldify Vapoursynth filter
Now in the script is generate the string "dd_method_params=[0.6,2,0.15,0.2]", while should be generate "dd_method_params: list = [0.6, 2.0, 0.15, 0.2, False]" if "invert merger order" is unchecked and  "dd_method_params: list = [0.6, 2.0, 0.15, 0.2, True]" if "invert merger order" is checked.

Dan
Reply
DOH, forgot to add a variable to the string generation.
Updated the download, should be fixed now.

Cu Selur
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply
(16.03.2024, 11:38)Selur Wrote: DOH, forgot to add a variable to the string generation.
Updated the download, should be fixed now.

Cu Selur

The file in the zip is dated: 16/03/2024 09:37, so I think that is still the previous version since the behavior is still the same.

Dan
Reply
typo, should work now.
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply
Hello Selur,

  I'm looking to a way to stabilize the colors. This filter must be a temporal filter. 
 The simplest way is to average the current frames with the previous frames.
 I found the description of misc.AverageFrames
  But I was unable to find it.
 This code is not working:

clip = core.misc.AverageFrames(clip, [0.25, 0.25, 0.25])

 Do you know how I can activate it ?

Thanks,
Dan

P.S.
The new version is working.
Reply
Quote: I found the description of misc.AverageFrames
But I was unable to find it.
MiscFilter => https://github.com/vapoursynth/vs-miscfilters-obsolete
Quote:This code is not working:
Did you load the filter dll? (MiscFilters)
In a custom-section adding:
core.std.LoadPlugin(path="%FILTERPATH%/MiscFilter/MiscFilters/MiscFilters.dll")
would work. (assuming it's not loaded for another filter by Hybrid)
If it's used, for a specific dd_method I can adjust Hybrid to automatically load it.

Cu Selur
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply
Hello Selur,

  good news! I found an effective way to stabilize the clip's colors by using the filter AverageFrames.
  Unfortunately I cannot add it in my filter because in not working if called inside a vpy filter.
  So this filter must be managed directly in Hybrid's GUI.

   This filter act as a temporal filter since the average is performed both on past and future frames.
    The type of average can be controlled using the weights, the max number of weights is 31, and must be used a (integer) odd number of weights because it is used a central average.

    It is better add this filter as a post process filter in the "Coloring" page.
    The options to be added are:

    1) Number of frames (integer, max 31)
    2) The type of average: Central Average, Left Average (only past frames), Right Average (only future frames)
    3) Scene Change detection (boolean): if true in the case of change scene detection the future frames are not used

Weight computation:

Given N the number of frames detected [if N%2==0: N+=1, N=min(N,31)]

The lateral weights can be calculated as: Wi=trunc(100/N)
Then the central weight can be calculated as: Wc=100-(N-1)*Wi  

Supposing N=11, we have:

Wi=trunc(100/11)=9
Wc=100-9*10=10.

Example of "Central Average" with 11 frames
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="709", range_s="limited", dither_type="error_diffusion")
clip = core.misc.AverageFrames(clip, [9, 9, 9, 9, 9, 10, 9, 9, 9, 9, 9], scale=100, scenechange = True, planes=[1,2])


Example of "Left Average" with 11 frames
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="709", range_s="limited", dither_type="error_diffusion")
clip = core.misc.AverageFrames(clip, [17, 17, 17, 17, 17, 15, 0, 0, 0, 0, 0], scale=100, scenechange = True, planes=[1,2])

Example of "Right Average" with 11 frames
clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="709", range_s="limited", dither_type="error_diffusion")
clip = core.misc.AverageFrames(clip, [0, 0, 0, 0, 0, 15, 7, 17, 17, 17, 17], scale=100, scenechange = True, planes=[1,2])

The Average must be performed on YUV color-space, using only the plans "U","V", because we are interested in stabilize the chroma components.

The attached file VideoTest_small1_DV+DD_AF31C.zip is an example of result obtained using a "Central Average" with 31 frames and scenechange =False, using the code

clip = core.resize.Bicubic(clip=clip, format=vs.YUV420P10, matrix_s="709", range_s="limited", dither_type="error_diffusion")
clip = core.misc.AverageFrames(clip, [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3], scale=100, scenechange = False, planes=[1,2])

As reference I attached also the file VideoTest_small1_DV+DD.zip that was obtained using the default settings

from vsdeoldify import ddeoldify
clip = ddeoldify(clip=clip)

I hope that you will include this filter Hybrid. Angel

Thanks,
Dan


Attached Files
.zip   VideoTest_small1_DV+DD.zip (Size: 955,94 KB / Downloads: 31)
.zip   VideoTest_small1_DV+DD_AF31C.zip (Size: 764,14 KB / Downloads: 27)
Reply
Quote:Unfortunately I cannot add it in my filter because in not working if called inside a vpy filter.
any details on that?
I think the most sensical way would be to write a Python script which stabilizes the chroma using AverageFrames.
=> I'll think about it a bit. Smile

Cu Selur
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply
Does:
import math

def weights(frames, mode):
    if frames % 2 == 0 or frames > 31:
        raise ValueError("Frames must be an odd number less than or equal to 31.")
    
    if mode not in ['left', 'center', 'right']:
        raise ValueError("Mode must be 'left', 'center', or 'right'.")
    
    array = [0] * frames
    
    if mode == 'center':
        array = [100 // frames] * frames
        array[frames // 2] = array[frames // 2] + 100 % frames
    else:
        array[:(frames // 2) - 1] = [100 // (frames // 2 + 1 ) + 1]  * (frames // 2)
        array[frames // 2] = 100 // (frames // 2 + 1) - (frames // 2)
        if mode == 'right':
            array = array[::-1]
    
    return array

# Example usage:
frames = 7
mode = 'left'
result = weights(frames, mode)
print(result)
seem correct to you to calculate the weights?

Cu Selur
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply
I rewritten the filter and now it is working, here python code

def vs_clip_color_stabilizer(clip: vs.VideoNode = None, nframes: int = 5, scenechange: bool = True) -> vs.VideoNode:
   
    clip_yuv = clip.resize.Bicubic(format=vs.YUV444PS, matrix_s="709", range_s="limited")
   
    if nframes%2==0:
        nframes +=1
   
    N = max(1, min(nframes, 31))
   
    Wi = math.trunc(100.0/nframes)
    Wc = 100-(N-1)*Wi
    Nh = round((N-1)/2)
   
    weight_list = list()
    for i in range(0, Nh):
        weight_list.append(Wi)
    weight_list.append(Wc)
    for i in range(0, Nh):
        weight_list.append(Wi)
   
    clip_yuv = vs.core.misc.AverageFrames(clip_yuv, weight_list, scenechange = True, planes=[1,2])           
   
    # convert the clip format for deoldify and std.Levels() to RGB24
    clip_rgb = clip_yuv.resize.Bicubic(format=vs.RGB24, matrix_in_s="709", range_s="limited", dither_type="error_diffusion")
   
    return clip_rgb

I will add this filter directly in ddeoldify, but the plugin "MiscFilters.dll" must be loaded by Hybrid.

Thanks,
Dan
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)