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.


Go Back   Doom9's Forum > Capturing and Editing Video > VapourSynth

Thread Tools Search this Thread Display Modes
Old 11th February 2022, 22:31   #1  |  Link
Registered User
Join Date: Jan 2022
Posts: 1
Help converting old avisynth function

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:
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
Katherine1 is offline   Reply With Quote
Old 12th February 2022, 12:27   #2  |  Link
Registered User
Selur's Avatar
Join Date: Oct 2001
Location: Germany
Posts: 7,337
no direct solution, but some hints, that might help:
Cu Selur
Hybrid here in the forum, homepage
Selur is offline   Reply With Quote
Old 12th February 2022, 20:02   #3  |  Link
Registered User
Join Date: Sep 2007
Posts: 5,409
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


mwlmask l1 = 180

mwlmask l1 = 220

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")
poisondeathray is offline   Reply With Quote

avisynth, scripting, scripts, vapoursynth

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +1. The time now is 23:42.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.