alex_x
帖子: 9
注册时间: 2018-07-14 1:19

mask bright area!

Hi everyone , hope you guys are good.


I have question about vapourynth ,
is there a function or method to mask the bright area instead of dark area and filtering the bright area ?

Regards!
头像
Muonium
帖子: 42
注册时间: 2016-06-18 8:48

Re: mask bright area!

Hi.

I can't remember which script has such function, but you can do it manually.

For example, suppose we want to process a grayscale image (format=vs.GRAY8), we can use the following code to construct a simple luma mask:

代码: 全选

mask = core.std.Expr(src, 'x 128 > 255 0 ?')
which classifies the pixels of the image according to their luma values.

Subsequently, we can use such mask to filter the bright area only by:

代码: 全选

bright_flt = core.std.MaskedMerge(src, flt, mask)
where "flt" is the filtering result of some function.

(Clearly, the construction of such mask is not limited to the case above, which is worth to explore by oneself.)
alex_x
帖子: 9
注册时间: 2018-07-14 1:19

Re: mask bright area!

Thank you very much it works =)
alex_x
帖子: 9
注册时间: 2018-07-14 1:19

Re: mask bright area!

ok one more Q,
if I want to mask the dark area, how its should be? less than 128?
头像
Muonium
帖子: 42
注册时间: 2016-06-18 8:48

Re: mask bright area!

Right
alex_x
帖子: 9
注册时间: 2018-07-14 1:19

Re: mask bright area!

Thanx Muonium!

Ok, if I use depth(src,10 or 16) instead of 8 depth, it will make any difference in result ,?

regards!
头像
Muonium
帖子: 42
注册时间: 2016-06-18 8:48

Re: mask bright area!

Yes, the formula then should be
'x 512 > 1023 0 ?' and 'x 32768 > 65535 0 ?'
for 10 and 16 bitdepth respectively.
alex_x
帖子: 9
注册时间: 2018-07-14 1:19

Re: mask bright area!

Thank you very much Muonium

Regards!

回到 “VapourSynth”