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.)