Clamp

This node constrains, or clamps, values in the selected channels to a specified range. By default, it clamps all channels to values between 0 and 1. This can be useful for ensuring that the input’s blackest blacks and whitest whites will be visible on an intended display device, or for restricting data fed to a subsequent node that does not support numbers outside this range.

See also ClipTest.

Inputs and Controls

Connection Type

Connection Name

Function

Input

unnamed

The image sequence whose values you want to clamp.

mask

An optional image to use as a mask. By default, the clamp is limited to the non-black areas of the mask.

At first, the mask input appears as triangle on the right side of the node, but when you drag it, it turns into an arrow labeled mask. If you cannot see the mask input, ensure that the mask control is disabled or set to none.

Control (UI)

Knob (Scripting)

Default Value

Function

Clamp Tab

channels

channels

all

The effect is only applied to these channels.

If you set this to something other than all or none, you can use the checkboxes on the right to select individual channels.

minimum

minimum

0

The lower clamp value. By default, all values that are lower than this number are set to this value. For example, if you set this to 0.2, any value below 0.2 is set to 0.2. This has the effect of causing black values to go gray.

However, if you check enabled next to MinClampTo, all values that are lower than this number are set to the MinClampTo value. For example, if you set this to 0.2 and MinClampTo to 0.4, any value below 0.2 is set to 0.4.

minimum_enable

enabled

Whether to clamp selected channels to a minimum value. Disabling both minimum and maximum effectively disables the node.

maximum

maximum

1

The upper clamp value. By default, all values that are higher than this number are set to this value. For example, if you set this to 0.8, any value above 0.8 is set to 0.8. This has the effect of causing white values to go gray.

However, if you check enabled next to MinClampTo, all values that are higher than this number are set to the MaxClampTo value. For example, if you set this to 0.8 and MinClampTo to 0.6, any value above 0.8 is set to 0.6.

maximum_enable

enabled

Whether to clamp selected channels to a maximum value. Disabling both minimum and maximum effectively disables the node.

MinClampTo

MinClampTo

0

The value to which low illegal values are clamped when MinClampTo is enabled. This sets the clamped areas to a custom color, allowing you to visualize the clamped range or create graphic effects.

MinClampTo_
enable

disabled

When enabled, all values below minimum are clamped to the MinClampTo value.

When disabled, all values below minimum are clamped to the minimum value.

MaxClampTo

MaxClampTo

1

The value to which high illegal values are clamped when MaxClampTo is enabled. This sets the clamped areas to a custom color, allowing you to visualize the clamped range or create graphic effects.

MaxClampTo_
enable

disabled

When enabled, all values above maximum are clamped to the MaxClampTo value.

When disabled, all values above maximum are clamped to the maximum value.

mask

N/A

disabled

Enables the associated mask channel to the right. Disabling this checkbox is the same as setting the channel to none.

maskChannelInput

none

The channel to use as a mask. By default, the clamp is limited to the non-black areas of this channel.

inject

inject

disabled

Copies the mask input to the predefined mask.a channel. Injecting the mask allows you to use the same mask further downstream.

invert

invert_mask

disabled

Inverts the use of the mask channel so that the clamp is limited to the non-white areas of the mask.

fringe

fringe

disabled

When enabled, only apply the effect to the edge of the mask.

When disabled, the effect is applied to the entire mask.

(un)premult by

N/A

disabled

Enables the associated channel to the right. Disabling this checkbox is the same as setting the channel to none.

unpremult

none

The image is divided by this channel before being processed, and multiplied again afterwards.

If you are using premultiplied input images, you may want to check (un)premult by and select rgba.alpha here. This will simulate doing the clamp before the premultiplication was done. It is the same as adding an Unpremult node before this node and a Premult node after, but allows you to work faster if you’re only using one color correct node.

If you are using unpremultiplied input images, you should leave this set to none.

invert

invert_unpremult

disabled

Inverts the use of the (un)premultiply channel.

mix

mix

1

Dissolves between the original image at 0 and the full clamp effect at 1.

Step-by-Step Guides

Clamping Channel Values