I am trying to only target the character's face. I am almost close to perfecting the mask, but I would like to bypass the whites of the character's eyes, and his outfit which is white-ish. Orange is just so you can see where I want to apply the filter. Attached is a sample of what I've been able to achieve with this script. Any help with adjusting would be greatly appreciated.
Code:AVISource("blah.avi") a=last b=blankclip(a, color=color_orange) mask = mt_binarize(threshold=65, Levels(50, 0.6, 255, 16, 255). FastLineDarkenMOD(100). santiag()) Overlay(a,b,mask=mask)
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays!
+ Reply to Thread
Results 1 to 10 of 10
Thread
-
-
simply using brightness isn't going to work.
-
I came up with this:
Code:AviSource("10038-10072.avi") orange = BlankClip(last, color=color_orange) hsmask = MaskHS(StartHue=110, EndHue=130, MinSat=30, MaxSat=70).Spline36Resize(width, height).ConvertToYV12() bmask1 = mt_binarize(120) bmask2 = mt_binarize(145) bmask = Overlay(bmask1, bmask2, mode="subtract") fullmask = Overlay(hsmask, bmask, mode="multiply").Blur(1.0) Overlay(last, orange, mask=fullmask)
mt_binarize is used to make a mask of only parts of the picture whose brightness is greater than 120, and another mask where the brightness is greater than 145. The latter is subtracted from the former to give a mask that is only parts of the picture with a brightness between 120 and 145.
hsmask and bmask are then multiplied together. Since each pixel in the masks is either 0 or 255 this is equivalent to a logical AND: 0*0=0, 0*255=0, 255*0=0, 255*255=255. So the final masks is only pixels that are the right color AND the right intensity. The resulting mask is blurred a bit to soften the edges.
Finally, the fullmask is used to overlay the orange color. A bit of that object at the left edge of the frame is colored too. Tweaking the thresholds might help with that.
[Attachment 60371 - Click to enlarge] -
With YV12 video the U and V planes are half the size (each dimension) of the Y plane. So MaskHS delivers a 360x240 mask from the 720x480 frame. The mask must be brought back to the full frame size.
-
Ok, now I understand. I notice that as I change the values in mt_binarize, I can cover different areas as needed in different video scenes. This is pretty damn fantastic. Thanks jagabo, for your script and thorough explanation.
I saved your script and explanations as comments on my script for future use.
Is there a rule of thumb with value numbers, depending on colors? For example if I were to only want to filter blue, or red or just green -
If you look at the docs for MaskHS you'll see a chart for the primary colors.
http://avisynth.nl/index.php/MaskHS
[Attachment 60375 - Click to enlarge]
Others colors you can estimate from the chart then experiment to you find what you need.
And note, I gave you the tools to understand this before:
https://forum.videohelp.com/threads/394036-using-masks-to-target-specific-colors/page2...hs#post2584960
The colored boxes represent the UV vector map, the same as the maskhs diagram above, except the colors are shown within the graph rather than just a circle around the edges. U increases horizontally from left to right. V increases vertically from top to bottom. Saturation increases from the center to the edges. The mask generated from the indicated values is the black box/circle/wedge. That is, the mask was used to overlay black over the full color map.
Hue and Saturation are the same as U and V, except HS is expressed in polar coordinates (angle, radius) rather than Cartesian coordinates (X,Y).
https://en.wikipedia.org/wiki/Polar_coordinate_system
https://en.wikipedia.org/wiki/Cartesian_coordinate_systemLast edited by jagabo; 19th Aug 2021 at 17:55.
Similar Threads
-
need assistance with creating a line mask for a cartoon
By Betelman in forum RestorationReplies: 5Last Post: 18th Jul 2021, 19:16 -
Help with My Script Motion Mask for two videos
By Kuronoe in forum Newbie / General discussionsReplies: 5Last Post: 28th Jan 2021, 18:41 -
Help with My Scriot Motion Mask for two videos
By Kuronoe in forum Newbie / General discussionsReplies: 0Last Post: 28th Jan 2021, 09:46 -
Mask dark or bright area
By Tornado in forum Newbie / General discussionsReplies: 1Last Post: 13th Jul 2018, 19:57 -
Mask question
By Aludin in forum EditingReplies: 12Last Post: 11th Jan 2017, 23:31