Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
![]() |
#1 | Link |
Registered User
Join Date: Jan 2022
Posts: 1
|
Help converting old avisynth function
Hey,
I'm currently working on converting a few scripts to vapoursynth for a few reasons, (more familiar with python, easier to set up environment thanks to AUR, some vapoursynth plugins like VSGAN, etc.), and I've basically got everything ported over except this one function. This function does a quick and dirty removal of most of the green color gamut. It does this because it's being used on some old video from those first-generation camcorders that would get those bright blobs of color in bright spots of the image. The video in question has bright green blobs. Funny thing is that the color gamut of VHS at that time is so limited that actual greens in the image remain fine while the unnatural greens from that artifact just get desaturated. Anyway, the issue I've run into with this function is that basically none of the functions it uses exist in vapoursynth. Is there a good way to do this in vapoursynth? Is there a plugin or group of plugins that could accomplish this? Here is the function: Code:
function removeAllGreen(clip a) { gmask = Overlay(a.UtoY().invert(), a.VtoY().Invert(), mode="multiply").BilinearResize(a.width, a.height).ColorYUV(off_y=-65).ColorYUV(gain_y=3000) return Overlay(a, Tweak(a, sat=0.0), mask=gmask) # overlay original with greyscale, only where green } |
![]() |
![]() |
![]() |
#2 | Link |
Registered User
Join Date: Oct 2001
Location: Germany
Posts: 7,148
|
no direct solution, but some hints, that might help:
Cu Selur |
![]() |
![]() |
![]() |
#3 | Link |
Registered User
Join Date: Sep 2007
Posts: 5,285
|
It's too bad vapoursynth is less mature than avisynth and missing some common functions
A different approach would be to mask a certain range of the green channel in RGB, using a luma mask such as mwlmask The results are slightly different , and you won't get the same results from a G channel derived mask - but you can adjust the range, feather the edges (blur the mask) if you need to . (Another useful tool missing is Masktools2) eg. test source https://upload.wikimedia.org/wikiped...RGB%29.svg.png removeAllGreen https://i.postimg.cc/fy7s88Gm/removeallgreen.png mwlmask l1 = 180 https://i.postimg.cc/g22pKqNL/mwlmask-180.png mwlmask l1 = 220 https://i.postimg.cc/vm1dJ8RQ/mwlmask-220.png AVS Code:
ImageSource("1024px-Color_circle_(RGB).svg.png") ConvertToPlanarRGB() ConvertBits(16) ConvertToYUV444(matrix="rec709") removeAllGreen Code:
clip = core.imwri.Read(r'1024px-Color_circle_(RGB).svg.png') y = core.resize.Bicubic(clip, format=vs.YUV444P10, matrix_s="709") nosat = adjust.Tweak(y, sat=0, coring=False) g = core.std.ShufflePlanes(clip, planes=1, colorfamily=vs.GRAY) gm = mwlmask(g, l1=220, h1=255) gm = core.fmtc.bitdepth (gm, bits=10, fulls=True, fulld=True) ov = haf.Overlay(y, nosat, mask=gm) #ov = core.resize.Bicubic(ov, format=vs.RGB24, matrix_in_s="709") ov.set_output() |
![]() |
![]() |
![]() |
Tags |
avisynth, scripting, scripts, vapoursynth |
Thread Tools | Search this Thread |
Display Modes | |
|
|