From Avisynth wiki
Jump to: navigation, search
Author Ignus2
Version 26th May 2007
Category Debug filter
License GPLv2
Discussion Doom9 Forum


[edit] Description

ColorDiff makes a greyscale (Y8) frame according to the input frame's pixels' "distance" from a specified color. The diff is calculated by simply getting the diff of the individual color components from the desired color's components and summing them up. Also, weights can be set for the individual diffs. It can work in YUV, RGB and HSL (wikipedia) mode. The resulting Y8 frame is greyscale. It's a kind of MaskHS() in a non-binary (greyscale) way.

Note: ColorDiff is a C-plugin so it must be loaded using LoadCPlugin, except if you're using AviSynth+, it allows autoloading of C-plugins.

[edit] Requirements

[edit] Syntax and Parameters

ColorDiff(clip, int "c1", int "c2", int "c3", float "w1", float "w2", float "w3", int "threshold", string "colorspace")

clip    clip: input clip, can be YUY2 or YV12 for "YUV" colorspace, or RGB for "RGB" or "HSL" colorspace
int     c1 (range: [0-255] for Y, [0-360] for H): desired color component 1 (Y, R, H)
int     c2 (range: [0-255]): desired color component 2 (U, G, S)
int     c2 (range: [0-255]): desired color component 3 (V, B, L)
float   w1 (default: 1.0): weight of color component 1
float   w2 (default: 1.0): weight of color component 2
float   w3 (default: 1.0): weight of color component 3
int     threshold: if calculated distance > threshold then result will be black.
         Otherwise result will be white.
         -1 means don't use thresholding, result will be the calculated diff value,
         clamped to 255, then inverted (substracted from 255).
string  colorspace: the colorspace used to calculate the distance. Can be "YUV", "RGB" or "HSL".
         The desired color components (c1, c2, c3) must also be given in this colorspace.
output: Y8 greyscale (or binary) mask

HSL values are calculated from RGB according to

[edit] Examples

ColorDiff(c1=100, c2=100, c3=100, w1=2.0, w2=2.0, w3=2.0, colorspace="YUV")

[edit] Changelog

Version      Date            Changes
2007/05/26 - latest release 2007/05/09 - initial release

[edit] Archived Downloads

Version Download Mirror

[edit] External Links

Back to External Filters

Personal tools