-
-
Notifications
You must be signed in to change notification settings - Fork 6
Dither
Bit-depth conversion with dithering — a port of fmtconv's fmtc.bitdepth plus the depth-dither modes from zimg (the engine behind resize.Point).
Converts a clip to another bit depth and/or sample type, applying a chosen dither pattern when reducing precision.
vszip.Dither(vnode clip, int bitdepth[, int dither_type=2, int sample_type, bint fulls, bint fulld])-
clip:
Clip to process. 8-16 bit integer or 16/32-bit float, any planar/gray color family. -
bitdepth:
Target bit depth. Integer output:8-16. Float output:16or32. -
sample_type: (Default:
1(float) whenbitdepth == 32, else0(integer))
Output sample type:0= integer,1= float. A float output is only valid withbitdepth16or32. -
dither_type: (Default: 2)
Dither pattern:# Mode Source 0 Round (no dither) zimg/fmtc 1 Ordered (Bayer) zimg 2 Random (blue noise) zimg 3 Error diffusion (Floyd-Steinberg) zimg 4 Ordered (Bayer) fmtc 5 FilterLite error diffusion fmtc 6 Stucki error diffusion fmtc 7 Atkinson error diffusion fmtc 8 Floyd-Steinberg error diffusion fmtc 9 Ostromoukhov error diffusion fmtc 10 Void-and-cluster fmtc 11 Quasirandom fmtc -
fulls: (Default:
Truefor RGB, elseFalse)
Treat the source as full range. When neitherfullsnorfulldis set the source's range prop passes through unchanged. -
fulld: (Default: same as
fulls)
Produce full-range output. If eitherfullsorfulldis given explicitly, the output's_ColorRangeprop is stamped accordingly; otherwise the source prop is kept.
- An identity conversion (same depth, sample type and range) is a pure passthrough for every mode — following zimg, dithering to the same depth only adds noise, so it is skipped.
- Upconverting between limited-range integer depths is a pure bit-shift (no dither); dithering only kicks in when precision is actually reduced.
out = core.vszip.Dither(src, bitdepth=8) # 16 -> 8 bit, zimg random / blue noise (default)
out = core.vszip.Dither(src, bitdepth=8, dither_type=3) # zimg error diffusion
out = core.vszip.Dither(src, bitdepth=10, dither_type=8) # fmtc Floyd-Steinberg to 10 bit
out = core.vszip.Dither(src, bitdepth=32) # convert to 32-bit float
out = core.vszip.Dither(src, bitdepth=8, fulls=1, fulld=0) # full -> limited range conversion