-
Notifications
You must be signed in to change notification settings - Fork 1
AdaptiveBinarize
Julek edited this page Oct 6, 2024
·
2 revisions
Adaptive Binarize for Vapoursynth, based on OpenCV's Adaptive Thresholding.
vszip.AdaptiveBinarize(vnode clip, vnode clip2[, int c=3])
-
clip
A clip to process. It must be in YUV/GRAY 8-bit. -
clip2
Blurred clip to calculate the thresholding.
Gauss has a cleaner result and Mean/BoxBlur retains more detail. -
c
Controls the threshold, read the OpenCV doc for more details.
Default: 3.
This code in Vapoursynth:
import vstools
import vapoursynth as vs
core = vs.core
src8 = ...
luma = vstools.get_y(src8)
luma16 = vstools.depth(luma, 16)
blur16 = luma16.std.Convolution([1]*11, mode='hv')
blur8 = vstools.depth(blur16, 8)
binarize = core.vszip.AdaptiveBinarize(luma, blur8, c=3)
Has the same result as this in OpenCV:
binarize = cv.adaptiveThreshold(img, 255, cv.ADAPTIVE_THRESH_MEAN_C, cv.THRESH_BINARY_INV, 11, 3)
More example: flat_mask from jvsfunc