Blog of Silas Bempong

Poisson Blending vs Copy–Paste: Why Solving a PDE Eliminates Seams

The motivating question

If you’ve ever tried to copy an object from one photo into another, you’ve seen the problem immediately: seams.

Even with careful masking, edge feathering, and opacity tweaks, the composite still tends to look “pasted.” Our eyes are incredibly sensitive to discontinuities in edges and lighting, not just raw color differences.

So here’s the driving question:

Why does solving a Poisson equation eliminate seams better than any amount of feathering?
What does it mean to reconstruct an image by specifying its gradient field instead of its pixel values?

This post answers that question with a small, controlled experiment: implement a few “reasonable” naive baselines, then compare them against Poisson blending. This post includes optional “reproduce it yourself” steps using a small companion codebase (linked at the end).

Why naive copy–paste fails (even when you feather)

Let’s name the most common approaches:

All of these share the same foundational assumption:

Copy colors.

If your foreground object (the source) was captured under different lighting (or white balance, camera response, exposure, environment), then copying its absolute pixel values into a new background often creates an obvious boundary. Feathering can reduce harsh edges, but it often introduces haloing—a softer seam that’s still visibly wrong.

The key idea: match gradients, not colors

Poisson blending flips the problem on its head.

Instead of copying colors, it tries to copy structure:

Poisson blending reconstructs pixel values inside the pasted region so that:

That’s why it feels “magical”: it doesn’t hide the seam—it removes the inconsistency that creates it.

The math

Let Ω be the region we want to paste into the target image, and let u be the unknown (reconstructed) image over Ω.

We choose a guidance field v, usually the source gradient field: v=(source).

We solve the optimization problem:

minuΩuv2dx

subject to a boundary constraint (Dirichlet condition):

u=targeton Ω

The Euler–Lagrange equation yields the Poisson equation:

Δu=·v

Seamless copy–paste becomes a boundary-value PDE.

Discretizing it: a sparse linear system

On a pixel grid, the Laplacian Δ is approximated by a 5-point stencil. In its familiar form, it connects each pixel to its four immediate neighbors:

4ui,jui1,jui+1,jui,j1ui,j+1=bi,j

The right-hand side (b) comes from:

Stack these equations for every pixel in Ω and you get:

Au=b

where:

For RGB images, you solve one system per channel.

This is the core “aha”:

Gradient-domain image editing = solving a huge sparse linear system.

What the companion code implements

If you want to reproduce the figures and comparisons from this post, the companion code, find here, implements two complementary paths:

1) Practical Poisson blending (OpenCV)

OpenCV ships a production-quality implementation of Poisson blending via:

cv2.seamlessClone(src, dst, mask, center, cv2.NORMAL_CLONE)

The companion code wraps this call and uses it as the “real” Poisson baseline in the comparison grid.

2) A tiny PDE solver demo

To make the mechanism tangible, the companion code also includes a minimal Poisson solver for a small patch. The goal is not to beat OpenCV; it’s to show the mechanics:

This is a “baby version” of what OpenCV does at full scale.

The experiment: comparing methods side by side

The companion code can generate a comparison grid of:

  1. Hard mask paste
  2. Feathered mask paste
  3. Alpha blending
  4. Poisson blending (OpenCV seamless cloning)

There’s also an optional zoom crop for pixel-peeping the seam region (hair/fur, shadows, texture boundaries, etc.).

Example inputs + output artifact

The visuals for this post come from running the comparison on:

foreground/object image
foreground/object image

background image
background image

The script writes a single side-by-side figure:

The grid comparing hard mask, feathering, alpha blend, and Poisson blending
The grid comparing hard mask, feathering, alpha blend, and Poisson blending

Why Poisson blending looks “more real”

A useful mental model:

So instead of “paint these colors here,” Poisson blending effectively asks:

“Find the image whose edges look like the source inside the region, while matching the target exactly on the boundary.”

Small, high-impact extensions

Final takeaway

Naive copy–paste edits pixel values while Poisson blending edits structure.It’s one of the cleanest “applied PDE” demos in computer vision:

Your computer solves a boundary-value problem to paste an object into a new scene without seams.

References

Companion code

To run the side-by-side comparisons and generate the figures, refer to the companion code linked here.