postprocess
stableImage post-processing effects operating on raw RGBA byte buffers, including grayscale, brightness, contrast, invert, sepia, threshold, box blur, vignette, bloom, tone mapping, color grading, sharpening, and gamma correction.
use plugin postprocess::{All functions accept an RGBA byte buffer produced by an image plugin, postprocess_grayscale, postprocess_brightness, …} Functions (15)
- All functions accept an RGBA byte buffer produced by an image plugin
- postprocess_grayscale Convert image to grayscale
- postprocess_brightness Multiply pixel brightness by a factor
- postprocess_contrast Adjust image contrast around mid-grey
- postprocess_invert Invert all pixel colours
- postprocess_sepia Apply sepia tone filter
- postprocess_threshold Binarise image at a luminance threshold
- postprocess_box_blur Apply a box blur of given radius
- postprocess_vignette Darken image edges toward the centre
- postprocess_bloom Add a glow effect to bright pixels
- postprocess_tone_map_reinhard Reinhard tone mapping operator
- postprocess_tone_map_aces ACES filmic tone mapping
- postprocess_color_grade Gamma + saturation colour grading
- postprocess_sharpen Sharpen image with unsharp-mask kernel
- postprocess_gamma Apply gamma correction to pixels
Convert image to grayscale
Converts each pixel to luminance using the ITU-R BT.601 formula (0.299R + 0.587G + 0.114B) and writes the same value to R, G, and B. Alpha is preserved.
use plugin postprocess::{postprocess_grayscale}
// Assume `pixels` is an RGBA byte buffer from the image plugin
let grey = postprocess_grayscale(pixels, 640, 480)
Multiply pixel brightness by a factor
Multiplies each RGB channel by factor. Values above 1.0 brighten; values below 1.0 darken. Result is clamped to 0–255. Alpha is preserved.
use plugin postprocess::{postprocess_brightness}
let brighter = postprocess_brightness(pixels, 800, 600, 1.4)
let darker = postprocess_brightness(pixels, 800, 600, 0.6)
Adjust image contrast around mid-grey
Adjusts contrast by pivoting around mid-grey (0.5). factor above 1.0 increases contrast; below 1.0 reduces it. Alpha is preserved.
use plugin postprocess::{postprocess_contrast}
let high_contrast = postprocess_contrast(pixels, 640, 480, 2.0)
Invert all pixel colours
Inverts each RGB channel (255 minus the channel value). Produces a photo-negative effect. Alpha is preserved.
use plugin postprocess::{postprocess_invert}
let inverted = postprocess_invert(pixels, 320, 240)
Apply sepia tone filter
Applies a warm sepia tone using standard sepia matrix coefficients. Gives images a classic antique photograph appearance.
use plugin postprocess::{postprocess_sepia}
let aged = postprocess_sepia(pixels, 640, 480)
Binarise image at a luminance threshold
Binarises each pixel: pixels with luminance >= value (0–255) become white (255), others become black (0). Alpha is preserved.
use plugin postprocess::{postprocess_threshold}
let binary = postprocess_threshold(pixels, 640, 480, 128.0)
Apply a box blur of given radius
Applies a box (mean) blur of the given pixel radius. Each pixel becomes the average of the square neighbourhood of side 2*radius+1. All four RGBA channels are blurred.
use plugin postprocess::{postprocess_box_blur}
let blurred = postprocess_box_blur(pixels, 800, 600, 3)
Darken image edges toward the centre
Darkens pixels toward the image edges based on their normalised distance from the centre. strength of 1.0 produces a moderate vignette; higher values produce stronger darkening.
use plugin postprocess::{postprocess_vignette}
let vignetted = postprocess_vignette(pixels, 1920, 1080, 1.5)
Add a glow effect to bright pixels
Extracts pixels brighter than threshold (luminance 0–255), blurs them with a small kernel, then adds the result back to the original image scaled by intensity. Simulates light scatter around bright sources.
use plugin postprocess::{postprocess_bloom}
let bloomed = postprocess_bloom(pixels, 1280, 720, 200.0, 0.8)
Reinhard tone mapping operator
Applies Reinhard tone mapping: each channel c becomes c / (1 + c) (after normalising to 0.0–1.0 range). Compresses HDR values into displayable range smoothly.
use plugin postprocess::{postprocess_tone_map_reinhard}
let mapped = postprocess_tone_map_reinhard(hdr_pixels, 1920, 1080)
ACES filmic tone mapping
Applies the ACES filmic tone mapping approximation, which produces rich contrast and colour saturation that mimics film stock. Better suited to game rendering than Reinhard.
use plugin postprocess::{postprocess_tone_map_aces}
let mapped = postprocess_tone_map_aces(hdr_pixels, 1920, 1080)
Gamma + saturation colour grading
Applies gamma correction (pow(channel, 1/gamma)) followed by saturation adjustment. saturation of 1.0 is unchanged; 0.0 is fully desaturated; values above 1.0 boost colours.
use plugin postprocess::{postprocess_color_grade}
// Warm, contrasty grade
let graded = postprocess_color_grade(pixels, 1280, 720, 2.2, 1.3)
// Desaturated grade
let grey = postprocess_color_grade(pixels, 1280, 720, 1.0, 0.0)
Sharpen image with unsharp-mask kernel
Sharpens the image using an unsharp-mask kernel where the centre weight is 1 + 4*strength and each cardinal neighbour is -strength. Higher strength produces more aggressive sharpening. Edge pixels are left unchanged.
use plugin postprocess::{postprocess_sharpen}
let sharp = postprocess_sharpen(pixels, 800, 600, 0.5)
Apply gamma correction to pixels
Applies gamma correction to each RGB channel: out = pow(in/255, 1/gamma) * 255. Common values are 2.2 (display gamma) and 0.4545 (linear-to-sRGB).
use plugin postprocess::{postprocess_gamma}
let corrected = postprocess_gamma(pixels, 640, 480, 2.2)