Nearest-neighbor fields
PatchMatch completion
Remove a red bottle from a gravel photograph. Matching patches fill the marked area while the rest of the image stays in place.
Try it
Runs locally in your browser. Uploaded images stay on your device.
The red bottle and its shadow are masked already. Add to the coral mask, or clear it and paint another region. Keyboard: focus the source and use arrows to move and paint.


Ready when you are.
Worker processing · local inputs · downloadable output
How it works
The red bottle and its shadow are masked already. Add to the coral mask, or clear it and paint another region. Keyboard: focus the source and use arrows to move and paint.
The bottle is replaced with gravel copied from unmasked parts of this same photograph. The canvas stays the same size, and known pixels are preserved. This is local completion; seam carving instead changes the image’s dimensions.
- Initialize a random field of candidate patches outside the hole.
- Alternate neighbor propagation with progressively smaller random searches.
- Reconstruct missing pixels from the matched patches and refine, while keeping known pixels unchanged.
Read the original research
Barnes, Shechtman, Finkelstein & Goldman · 2009
Computed examples
The original, the removal mask, and the completed image. The image dimensions stay unchanged.
Source photographs were generated for these studies. The displayed results were computed by the algorithms; they are not generated illustrations of an expected result. Published previews are compressed for the web.
Implementation and limits
A single-image completion loop built around PatchMatch. It can copy texture and nearby structure; it cannot invent a missing object or reconstruct a large unknown scene.
Interactive settings are bounded to keep the experiment practical in a browser. Higher detail can cost more processing time without guaranteeing a better result. The implementation and its tests are available in the source repository.