masks ¶
Functions:
-
range_mask
– -
stabilize_mask
–Generate a stabilization mask highlighting unstable regions between frames using temporal median and blur filtering.
-
strength_zones_mask
–Creates a mask based on a threshold strength, with optional adjustments using defined zones.
range_mask ¶
Source code in vsmasktools/masks.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
|
stabilize_mask ¶
stabilize_mask(
clip: VideoNode,
radius: int = 3,
ranges: FrameRangeN | FrameRangesN = None,
scenechanges: Iterable[int] | None = None,
kernel: BlurMatrix = MEAN_NO_CENTER,
brz: int = 0,
planes: Planes = None,
func: FuncExcept | None = None,
) -> VideoNode
Generate a stabilization mask highlighting unstable regions between frames using temporal median and blur filtering.
Useful for stabilizing credit masks.
Parameters:
-
clip
¶VideoNode
) –Input mask.
-
radius
¶int
, default:3
) –Temporal radius for filtering. Higher values smooth more. Defaults to 3.
-
ranges
¶FrameRangeN | FrameRangesN
, default:None
) –Frame ranges treated as scene changes.
-
scenechanges
¶Iterable[int] | None
, default:None
) –Explicit list of scenechange frames.
-
kernel
¶BlurMatrix
, default:MEAN_NO_CENTER
) –Blur kernel applied after the median step.
-
brz
¶int
, default:0
) –Threshold bias for binarization. Higher = stricter. Defaults to 0.
-
planes
¶Planes
, default:None
) –Which planes to process. Defaults to all.
-
func
¶FuncExcept | None
, default:None
) –Function returned for custom error handling. This should only be set by VS package developers.
Returns:
-
VideoNode
–A mask clip where white marks unstable areas and black marks stable regions.
Source code in vsmasktools/masks.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
strength_zones_mask ¶
strength_zones_mask(
base: SupportsFloat | VideoNode | None = None,
zones: (
Sequence[
tuple[FrameRangeN | FrameRangesN, SupportsFloat | VideoNode | None]
]
| None
) = None,
format: int | VideoFormatLike | HoldsVideoFormat = GRAYS,
length: int | None = None,
) -> ConstantFormatVideoNode
Creates a mask based on a threshold strength, with optional adjustments using defined zones.
Parameters:
-
base
¶SupportsFloat | VideoNode | None
, default:None
) –The base clip used to generate the strength mask. If set to None, a blank mask (all zeros) will be created using the specified format.
-
zones
¶Sequence[tuple[FrameRangeN | FrameRangesN, SupportsFloat | VideoNode | None]] | None
, default:None
) –Optional list of zones to define varying strength regions. Defaults to None.
-
format
¶int | VideoFormatLike | HoldsVideoFormat
, default:GRAYS
) –Pixel format for the mask. Defaults to vs.GRAYS.
-
length
¶int | None
, default:None
) –Total number of frames for the mask. If None, uses the length of the base clip.
Returns:
-
ConstantFormatVideoNode
–A mask clip representing the defined strength zones.
Source code in vsmasktools/masks.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
|