Image matting splits a photo into a foreground layer, a background layer, and a per-pixel opacity map, called the alpha matte. The split is badly under-determined: each pixel gives three observed color values but has seven unknowns. When a model gets it slightly wrong, the error people notice is rarely the one the benchmarks measure. The foreground color at wispy hair or fur keeps a tint of the old background, and this "bleeding" becomes a visible halo once the subject is pasted onto a new scene. Standard matting scores such as sum of absolute differences (SAD), mean squared error (MSE), gradient error and connectivity error are all computed on the alpha map alone. They ignore this tint entirely. They also penalize a hair strand shifted by one pixel more heavily than a blurred one, which pushes models toward waxy, smoothed mattes.
Quaternion methods, which treat an RGB pixel as a single hypercomplex number rather than three separate numbers, have been shown to reduce color bleeding in restoration. But they pay for it with slow quaternion convolutions and expensive quaternion factorizations. This note proposes moving that color structure out of the network and into a cheap, per-pixel objective. The proposed error measure splits foreground-color error into two parts: the part that leaks toward the true background color, and the part that points elsewhere. It computes this on composites blurred to roughly match human contrast sensitivity. The measure is first checked against human judgments of matting composites. It is then used as a training loss for an ordinary real-valued matting network, and compared directly with a quaternion-convolution network.
Core Claim
Two claims are tested, and each can fail on its own. The first claim is that people judging matting composites on new backgrounds penalize "leak toward the old background" much more than other color errors of the same size. It follows that a metric which separates leak from the rest of the error, and blurs away sub-pixel boundary jitter, will track human preference better than SAD, MSE, gradient error, CIELAB color difference, or LPIPS (a deep-feature perceptual distance).
The second claim is that the cross-channel benefit quaternion networks show in restoration can be recovered at real-valued inference cost by putting the quaternion product into the loss. This matters because inference cost is the overhead problem this line of work has not solved. If a quaternion-convolution matting network still beats a real network trained with the new loss, the second claim fails and the overhead is buying something real.
The mechanism is simple. Write the foreground error at pixel $i$ as the pure quaternion $e_i = \hat F_i - F_i$, and the direction from true foreground to true background as $d_i = B_i - F_i$. Both are read as $0 + ri + gj + bk$. Their Hamilton product separates into a scalar and a vector part:
$$e_i d_i = -(e_i \cdot d_i) + (e_i \times d_i),$$
This gives a signed leak term, $\ell_i = e_i \cdot d_i / \|d_i\|$, which measures how far the predicted foreground has drifted toward the background. It also gives an orthogonal term, $o_i = \|e_i \times d_i\| / \|d_i\|$, which captures every other color error. The proposed loss applies a Gaussian filter $G_\sigma$ to each term, following the contrast-sensitivity argument of PAMSE, and weights each by where the pixel sits in the matte:
$$\mathcal{L} = \sum_i w_i \big[\lambda_\ell\, (G_\sigma * \ell)_i^2 + \lambda_o\, (G_\sigma * o)_i^2\big] + \|G_\sigma * (\hat\alpha - \alpha)\|_2^2 .$$
Here $w_i = \alpha_i(1-\alpha_i)$ up-weights semi-transparent pixels, which are where bleeding is visible. The weights $\lambda_\ell$ and $\lambda_o$ are fit to human preference data rather than hand-set.
To be candid, the quaternion product here is a dot product and a cross product in RGB. The quaternion view is useful because it matches how QDIP-style methods bind color as one rotating and scaling vector. It is also cheap: one product costs 16 multiplies per pixel, applied only in the loss. The substance of the claim is the leak/orthogonal split that the compositing equation makes possible, not the algebra itself.
Where This Sits Relative to Prior Work
The motivation comes from three findings. First, QDIP-RED (Quaternion-based Deep Image Prior with Regularization by Denoising for Color Image Restoration) uses an untrained quaternion network inside a denoising-regularized solver and reports 28.60 dB versus 27.71 dB for real-valued DIP on Set12 at noise level 45. It explicitly notes much higher latency. We take its result as evidence that coupling color channels matters, and we test whether the coupling can be moved out of the architecture.
Second, the perceptual-metric literature (Wei Liu et al., Alahi et al.) shows that pixel losses prefer blurred edges to slightly shifted sharp ones. Work on compositing (Haochen Xue et al.) documents the same failure. Together these motivate the blur step.
Third, matting work names bleeding as the cost of estimating alpha alone. DRIP (DRIP) predicts the foreground jointly with a diffusion model and reports a 12.1% foreground SAD improvement on Composition-1k, which confirms that the foreground layer is where gains remain.
The method borrows from two sources. PAMSE (Perceptual Fidelity Aware Mean Squared Error) computes MSE after Gaussian smoothing. It reaches a Spearman correlation of 0.9162 on TID2008, against 0.7718 for plain MSE, at 2.6 times the cost of MSE, and it stays convex. We reuse its filter but apply it to composite-space leak terms rather than to whole images. PAMSE was only ever validated on uniform distortions, never on layer decomposition. The compositing equation and the closed-form color-line reasoning (A Closed Form Solution to Natural Image Matting) supply the geometry. Under that equation, $I-B$ is parallel to $F-B$, which is why "error along $d$" is the physically meaningful direction.
Several works bear on the idea without supplying it. Human Perception Modeling for Automatic Natural Image Matting invokes human perception but only as semantic trimap guidance, keeping pixel losses and metrics. We model perception of the error itself. BiRQA (BiRQA) shows that lightweight analytic features can reach SROCC 0.988 on LIVE, and that undefended deep metrics collapse to 0.30–0.57 under white-box attack on KADID-10k. That fragility is a warning against using a deep metric as a training target, and it argues for an analytic loss.
Two further constraints shape the design. The research file notes that general IQA metrics are calibrated on LIVE, CSIQ and TID-style distortions, not on bleeding. This is why we collect matting-specific judgments instead of trusting any existing metric. QMCUR (Efficient quaternion CUR method) shows that sampling-based quaternion factorizations lose accuracy under noise. That weighs against a factorization-heavy design and is part of why we avoid one altogether.
Research Program
The first stage builds a human-judgment set for matting errors, because none exists in the file. We take Composition-1k test foregrounds and new backgrounds, then generate composites from several sources. These include real matting outputs (Deep Image Matting, GCA-Matting, MatteFormer, and DRIP if it can be run) and controlled perturbations. The perturbations inject pure leak, pure orthogonal color error of matched magnitude, alpha blur, and alpha shifts of one or two pixels. Observers make paired two-alternative choices. The controlled pairs directly test whether leak is judged worse than orthogonal error, and whether shift is judged better than blur, as the perceptual literature predicts. We also use AIM-500 and P3M-500-NP for real-image composites, where ground-truth foregrounds allow.
The second stage fits $\lambda_\ell$, $\lambda_o$ and $\sigma$ on one half of the judgments and reports rank correlation on the held-out half. We compare against every existing matting metric and the color-difference alternatives.
The third stage trains a fixed real-valued architecture, a MatteFormer-style backbone with a foreground head, under three objectives: the standard alpha-plus-compositional-plus-L1 losses, the proposed loss, and ablations of it. The fourth stage builds a quaternion-convolution version of the same backbone with matched parameter count, trained with standard losses, and optionally with ours. Across all variants we measure inference latency and accuracy.
Baselines
The naive reference is the standard matting recipe from Deep Image Matting: alpha-prediction loss, compositional loss, and L1 on the foreground where one is predicted, all scored with SAD, MSE, gradient and connectivity error. We run it with the same backbone, data, schedule and number of hyperparameter trials as our loss. Beating it means lower human-preference error and lower leak without a worse alpha SAD.
The strongest non-diffusion matting competitor is MatteFormer (MatteFormer), which reports SAD 23.8 on Composition-1k. It is the strongest because it is the best trimap-based regression model in the file and runs at interactive cost. We reproduce it with its published recipe and then retrain it under our loss at equal compute. GCA-Matting (Natural Image Matting via Guided Contextual Attention), with SAD 35.28 and MSE 0.0091, serves as a secondary check that the effect is not tied to one architecture.
DRIP is the quality ceiling. It reports AIM-500 SAD 17.3 against 43.9 for automated baselines, plus the foreground gain above. We compare against it on human preference and latency, not as a matched-compute rival. A win here would be closing a meaningful fraction of the human-preference gap to DRIP at a small fraction of its runtime.
For the metric study, the baselines are SAD, MSE, gradient and connectivity on alpha; PAMSE on the composite; CIELAB color difference on the composite; LPIPS; and BiRQA. The strongest reported alignment numbers are BiRQA's SROCC of 0.988 on LIVE and PAMSE's 0.9162 on TID2008. Neither was measured on matting. There is no reported result on Lacuna for human alignment of any matting metric, so our metric must beat these baselines on our held-out judgments rather than against a published figure.
The key ablations remove the leak/orthogonal split, keeping blurred composite L1. They also remove the blur, and replace the split with CIELAB difference. The quaternion-network comparison isolates whether the algebra is more useful in the architecture than in the loss.
Why not just…?
Why not just use a perceptual color space like CIELAB or YCbCr in the loss? This is the most serious threat. CIELAB difference is cheap, well established, and already down-weights some color errors. However, it is blind to the direction of the background, so it cannot distinguish a tint toward the old backdrop from an equally large tint the other way. Bleeding is specifically the former. The controlled leak-versus-orthogonal pairs settle this directly. If observers do not treat these differently, the split has no value and the proposal reduces to "blurred CIELAB loss," which we would then report as the finding.
Why not just train with LPIPS or SSIM? SSIM is about ten times slower than MSE and non-convex, according to Xue et al.. Deep metrics are fragile to adversarial inputs according to BiRQA, which matters when a network is actively optimizing against the metric. Neither was calibrated on bleeding. We include LPIPS both as a training loss and as an evaluation metric at equal budget. If it matches our loss on held-out human preference, the analytic route offers only speed.
Why not just use a quaternion-convolution network, as QDIP-RED does? It might work. QDIP-RED's gain over real-valued DIP is real, but it comes with acknowledged latency, and it has not been separated from a plain weight-sharing effect. The parameter-matched quaternion backbone answers this. If it beats the real network trained with our loss on leak and human preference, then moving structure into the loss is insufficient, and the right follow-up is making quaternion layers faster.
Why not just use DRIP? DRIP's own authors say it is heavy and unsuited to real-time use. We report where it lands on human preference so the latency-quality trade-off is explicit rather than assumed.
Decisive Checks
Three results decide the proposal. The first is whether matched-magnitude leak is judged worse than orthogonal error, and whether one-pixel shifts are judged better than blur. If both fail, the metric's premise is wrong. The second is whether the fitted metric beats SAD, CIELAB difference and LPIPS in held-out rank correlation with human choices, and whether MatteFormer retrained with it shows lower leak and higher human preference with alpha SAD within noise of 23.8. The third is whether the quaternion-convolution backbone adds anything beyond the loss once parameters are matched, reported alongside measured inference latency. A negative third result, meaning the loss alone suffices, would be the most useful outcome for the quaternion field, because it would say the overhead can be avoided.
References
- Quaternion-based deep image prior with regularization by denoising for color image restoration
- Bayesian Tensor Inference for Sketch-Based Facial Photo Hallucination
- Perceptual Losses for Real-Time Style Transfer and Super-Resolution
- Image Blending Algorithm with Automatic Mask Generation
- DRIP: Unleashing Diffusion Priors for Joint Foreground and Alpha Prediction in Image Matting
- Perceptual Fidelity Aware Mean Squared Error
- A Closed Form Solution to Natural Image Matting
- Human Perception Modeling for Automatic Natural Image Matting
- BiRQA: Bidirectional Robust Quality Assessment for Images
- Efficient quaternion CUR method for low-rank approximation to quaternion matrix
- Deep Image Matting
- MatteFormer: Transformer-Based Image Matting via Prior-Tokens
- Natural Image Matting via Guided Contextual Attention