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. |
7th January 2011, 13:35 | #1 | Link | |
Registered User
Join Date: Nov 2009
Posts: 2,361
|
Mask function help
Im trying to make a function for masking based on luma (from this post). I tried to convert it to masktools2 and inverse the mask effect (now it affects to bright areas). I would like to make a bool operator for chossing whether bright or dark areas, and another one where I can define by a string the filter I want to apply to chosen area.
Quote:
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread Last edited by Dogway; 7th January 2011 at 13:50. |
|
7th January 2011, 14:35 | #2 | Link |
Registered User
Join Date: Apr 2002
Location: Germany
Posts: 5,391
|
You're thinking too complicated.
To reverse the whole logic to "leave dark untouched, filter bright", you just swap the clip arguments of mt_merge. FitY2UV doesn't exist anymore. In exchange, mt_merge now has the toggle "luma=true/false". When true, luma mask is used for the UV channels, too. String evaluation is of course possible. But why? I don't see any benefit to declare filtersting="""MyFilter(with,"some",parameter)""" before, and use some doggerel result = Eval( string(clip) + filterstring ) in the function, when you can as well directly use a clip: filter=MyFilter(with,"some",parameter), and simply use result = filter in the function. (You need string evaluation if you want to apply a filter to something that is constructed only in the function. But not for a basic input clip that gets used as-is.) Code:
function drkbrgtfltr(clip input, clip filtered, int "black", int "white", bool "darkfilt") { LO = string(default(black, 24)) HI = string(default(white, 48)) darkfilt = default(darkfilt,true) darkmask = input.mt_lut("x "+LO+" < 255 x "+HI+" > 0 255 x "+LO+" - 255 "+HI+" "+LO+" - / * - ? ?",U=1,V=1) darkfilt ? mt_merge(input, filtered, darkmask, luma=true, U=3,V=3) \ : mt_merge(filtered, input, darkmask, luma=true, U=3,V=3) return last }
__________________
- We´re at the beginning of the end of mankind´s childhood - My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!) Last edited by Didée; 7th January 2011 at 15:14. Reason: on darkmask creation, U=1,V=1 is sufficient |
7th January 2011, 15:00 | #3 | Link |
Registered User
Join Date: Nov 2009
Posts: 2,361
|
Oh thanks for the input! looks I was close... :P the first thing I tried was swaping but I got a green screen that's why all the thinking afterwards. Yes, define the filter outside function might be better, less hassle I guess.
__________________
i7-4790K@Stock::GTX 1070] AviSynth+ filters and mods on GitHub + Discussion thread |
7th January 2011, 15:15 | #4 | Link | |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Quote:
Code:
input filtered=Eval(filterString) |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|