Compare

Compares two textures pixel by pixel and shows where one is brighter, equal or different.

Outputs

NameTypeDescription
OutputTextureWhite where the comparison holds and black where it does not, or the difference between the two inputs.

Inputs

NameTypeDescription
ATextureThe texture on the left of the comparison, stretched over the whole output.
BTextureThe texture on the right of the comparison, stretched over the whole output.

Parameters

NameTypeDescription
SizeEnumWhere the size of the output comes from. Largest and Smallest take it from both inputs, A and B from that input, and Custom from Resolution.Choices: Largest, Smallest, A, B, Custom
ResolutionVector 2 IntThe width and height of the output in pixels. Only present when Size is Custom.
OperationEnumHow the two inputs are compared, read from A to B.Choices: Greater, Greater or Equal, Less, Less or Equal, Equal, Not Equal, Difference
SourceEnumWhich value of a pixel is compared. Luminance weighs the channels the way the eye sees them, and Per Channel compares red, green and blue each on their own.Choices: Luminance, Average, Red, Green, Blue, Alpha, Per Channel
ToleranceFloatHow far apart two values may be and still count as equal, between 0 and 1.
SoftnessFloatHow wide the transition from black to white is, in the same units as the values. 0 gives a hard cut. Not used by Difference.
FilteradvancedEnumHow a stretched input is read between its pixels. Nearest keeps hard pixels, and Linear Nice keeps edges next to transparency clean.Choices: Nearest, Linear Fast, Linear Nice
FormatadvancedEnumThe pixel format of the output. Auto is one channel of gray, or the channels of the wider input when Source is Per Channel.

The Compare operator holds two textures against each other, pixel by pixel, and is white where the comparison holds and black where it does not. Use it to find where two pictures differ, such as what moved between two video frames.

In Greater mode, the output is white where A is brighter than B by more than the tolerance. In Greater or Equal mode, it is also white where the two are within the tolerance of each other. Less and Less or Equal mode do the same with B brighter than A. In Equal mode, the output is white where the two are within the tolerance, and in Not Equal mode where they are further apart. In Difference mode, the output is how far apart the two are, less the tolerance, instead of black or white.

Pictures rarely match exactly, and a camera adds noise. A little tolerance makes Equal and Not Equal usable, and a little softness stops edges from flickering. To compare a picture against one color, connect a small Color as B. To compare it against a fixed brightness, use Threshold.

See also Threshold, Color.

Keywords: greater, less, equal, difference, mask, motion detection, change, diff