Skip to content

Effects

keyed_extras.effects.blur

Blur effects.

Blur

Apply a Gaussian blur to an image.

This class implements an efficient Gaussian blur by splitting the 2D convolution into two 1D passes (horizontal and vertical).

Parameters:

Name Type Description Default
radius float

Standard deviation of the Gaussian kernel, controlling blur strength. Larger values create more pronounced blurring effects.

required

keyed_extras.effects.bloom

Bloom effects.

Bloom

Apply a standard, single pass bloom effect to an image.

The Bloom effect creates a soft glow around bright areas of an image.

This effect extracts pixels above a luminance threshold, applies Gaussian blur, and then combines the result with the original image.

Parameters:

Name Type Description Default
threshold float

Luminance value (0.0-1.0) above which pixels will bloom.

0.7
radius float

Size of the bloom effect in pixels. Higher values create a larger glow.

3.0
intensity float

Strength (non-negative value) of the bloom effect.

1.0

MultiPassBloom

Apply a multi-pass bloom effect to an image.

This bloom effect creates a pyramid of progressively downsampled images, applies the bloom effect at each level, and then combines them back together.

This technique tends to produce stronger blooms.

Parameters:

Name Type Description Default
threshold float

Luminance value (0.0-1.0) above which pixels will bloom.

0.7
radius float

Size of the bloom effect in pixels. Higher values create a larger glow.

3.0
intensity float

Strength (non-negative value) of the bloom effect.

1.0
num_passes int

Number of downsampling/upsampling passes to perform. Higher values create a more diffuse bloom.

5

ExponentialBloom

Apply a bloom effect with exponential falloff.

This bloom effect uses an exponential kernel to make the glow diminishe more rapidly with distance from bright areas, giving a more concentrated and intense bloom appearance.

Parameters:

Name Type Description Default
threshold float

Luminance value (0.0-1.0) above which pixels will bloom.

0.7
radius float

Size of the bloom effect in pixels. Higher values create a larger glow.

3.0
intensity float

Strength (non-negative value) of the bloom effect.

1.0
exponent float

Controls the falloff rate of the bloom. Higher values create a more concentrated bloom with sharper edges.

2.0

keyed_extras.effects.glow

Glow

Apply a uniform glow effect to an image.

This effect creates a soft luminosity across the entire image by applying a Gaussian blur and combining it with the original.

Note

This effect is functionally similar to Bloom with threshold=0. It may be deprecated in the future in favor of using the Bloom.

Parameters:

Name Type Description Default
radius float

Size of the glow effect in pixels. Higher values create a more diffuse glow.

3.0
intensity float

Strength of the glow effect.

1.5

keyed_extras.effects.color

Color manipulation effects for image processing.

ColorAdjust

Adjust image brightness, contrast, and saturation.

This effect provides basic color grading controls for manipulating the overall appearance of an image.

Parameters:

Name Type Description Default
brightness float

Multiplier for pixel brightness. Values above 1.0 increase brightness.

1.0
contrast float

Multiplier for contrast. Values above 1.0 increase contrast.

1.0
saturation float

Multiplier for color saturation. Values above 1.0 increase saturation, while 0.0 produces a grayscale image.

1.0

Invert

Invert the colors of an image while preserving alpha.

This effect performs a simple color inversion (255 - color value) on each RGB channel, creating a negative-like appearance. The alpha channel remains unchanged.

ColorQuantization

Reduce the number of distinct colors in an image.

This effect maps each pixel to the nearest color in a uniformly distributed color palette of the specified size.

Parameters:

Name Type Description Default
num_colors int

Total number of colors to use in the quantized image.

8

Palettize

Map image colors to a specific color palette.

This effect replaces each color in the image with the closest color from a predefined palette, useful for creating stylized visuals with a consistent color scheme.

Parameters:

Name Type Description Default
palette list[tuple[int, int, int]]

List of RGB tuples defining the target colors.

required
blend float

Amount of color blending between palette colors (0.0-1.0). At 0.0, pixels use their nearest palette color. Higher values blend between the two closest palette colors.

0.0

Posterize

Reduce color depth to create a poster-like appearance.

This effect reduces the number of color levels per channel, creating large areas of flat color with sudden transitions.

Parameters:

Name Type Description Default
levels int

Number of color levels per channel. Lower values create more dramatic posterization.

4

ChromaticAberration

Simulate lens chromatic aberration by offsetting color channels.

This effect shifts the red and blue channels in opposite directions, mimicking the optical distortion that occurs in camera lenses when different wavelengths of light focus at different positions.

Parameters:

Name Type Description Default
offset_x float

Horizontal displacement of color channels in pixels.

5.0
offset_y float

Vertical displacement of color channels in pixels.

5.0

keyed_extras.effects.displace

Displacement effects for creating distortion and turbulence in images.

This module provides various displacement effects that shift pixels based on noise patterns or other distortion algorithms. Can be used to create sketch-like, turbulence, or waves.

NoisyDisplace

Displace pixels by a 2D vector field of uniformally random noise.

Parameters:

Name Type Description Default
amplitude float

Maximum pixel displacement amount. Larger values yield more displacement.

5.0
seeth HasValue[float] | HasValue[int] | None

Value controlling the noise pattern changes. When this changes, the noise updates. For NoisyDisplace, there is no correlation between the size of the change in seeth and the size of the change in noise.

None

Displace

Creates coherent (locally smooth) distortion by displacing pixels using simplex noise.

Unlike NoisyDisplace (which uses uniform random noise), this effect uses simplex noise to create locally consistent displacement, resulting in a more fluid, wave-like distortion.

Parameters:

Name Type Description Default
amplitude float

Maximum pixel displacement amount. Larger values yield more displacement.

5.0
frequency float

Frequency of the noise pattern. Higher values create finer, more detailed displacement patterns, while lower values create broader, more gradual distortions across the image.

0.01
seeth HasValue[float] | HasValue[int] | None

Value controlling the noise pattern changes. When this changes, the noise updates. Small changes in seeth result in relatively small changes in noise.

None

keyed_extras.effects.dog

Edge detection using Difference of Gaussians (DoG) filter.

DifferenceOfGaussians

Edge detection and detail enhancement using Difference of Gaussians.

This effect creates an image where edges and details are enhanced by subtracting two Gaussian-blurred versions of the same image with different blur radii. The result approximates a band-pass filter that highlights features at a specific spatial frequency range.

Parameters:

Name Type Description Default
radius1 float

Radius for the first (smaller) Gaussian blur.

1.0
radius2 float

Radius for the second (larger) Gaussian blur. radius2 should be larger than radius1.

2.0

keyed_extras.effects.kuwahara

Non-linear smoothing filters based on the Kuwahara method.

BasicKuwahara

Edge-preserving smoothing filter.

The Kuwahara filter divides the area around each pixel into four overlapping quadrants, computes the mean and variance in each quadrant, and replaces the pixel with the mean color of the quadrant that has the smallest variance. This preserves edges while smoothing homogeneous areas, creating an effect similar to a watercolor or oil painting.

Parameters:

Name Type Description Default
radius int

Size of each quadrant in pixels. Larger values create a more pronounced painterly effect.

3

keyed_extras.effects.stylized

Halftone

Creates a monochrome print-like halftone effect using variable-sized dots.

Halftoning is a technique that simulates continuous tone imagery through the use of dots of varying size. This effect is commonly seen in newspapers, magazines, and comic books. This implementation uses a parametric dot pattern that varies in size based on the intensity of the image.

Parameters:

Name Type Description Default
dot_size int

Size of the halftone dots in pixels.

4
angle float

Rotation angle of the dot pattern in degrees.

45.0

CMYKHalftone

Creates a CMYK halftone effect with color separations.

This implementation simulates professional printing techniques by separating the image into Cyan, Magenta, Yellow, and Black (CMYK) channels and applying a different halftone angle to each channel.

Parameters:

Name Type Description Default
dot_size int

Size of the halftone dots in pixels. Default is 4.

4
c_angle float

Rotation angle for Cyan channel in degrees. Default is 15.0.

15.0
m_angle float

Rotation angle for Magenta channel in degrees. Default is 75.0.

75.0
y_angle float

Rotation angle for Yellow channel in degrees. Default is 0.0.

0.0
k_angle float

Rotation angle for Black channel in degrees. Default is 45.0.

45.0
intensity float

Overall intensity of the effect. Default is 1.0.

1.0

Painterly

Creates a painterly effect by simulating brush strokes.

This effect transforms images to appear as if they were painted with brush strokes, simulating techniques like impressionism or expressionism. It works by applying directional color strokes with varying sizes and slight color variations.

Parameters:

Name Type Description Default
brush_size float

Size of the simulated brush strokes in pixels.

5.0
stroke_density float

Density of brush strokes, from 0.0 to 1.0. Higher values create more strokes.

0.8
color_variation float

Amount of random color variation in strokes, from 0.0 to 1.0.

0.2
direction_noise float

Amount of randomness in stroke directions, from 0.0 to 1.0.

0.3

Dither

Creates a dithered effect using ordered dithering with a Bayer matrix.

Dithering is a technique used to simulate additional colors or gray levels by using patterns of dots. This implementation uses a 4x4 Bayer matrix for ordered dithering.

Parameters:

Name Type Description Default
levels int

Number of color levels per channel. Lower values create a more pronounced dithering effect with fewer colors.

4