Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

PatchMatch based Inpainting

License: MIT PyPI Downloads Ruff

This library implements the PatchMatch based inpainting algorithm. It provides both C++ and Python interfaces. This implementation is heavily based on the implementation by Younesse ANDAM: younesse-cv/PatchMatch, with some bug fixes, and updates.

Installation

pip install PyPatchMatch

Wheels for Linux, macOS and Windows ship the compiled library including the required OpenCV runtime, so no compiler or OpenCV installation is needed. On other platforms pip builds from the source distribution, which requires a C++17 compiler, CMake and the OpenCV development files (e.g. apt install libopencv-dev or brew install opencv).

Usage

Python (see examples/py_example.py):

import patchmatch

image = ...  # HxWx3 uint8 numpy array or PIL image
mask = ...  # HxW uint8 or bool numpy array or PIL image, non-zero marks the holes
result = patchmatch.inpaint(image, mask, patch_size=3)

The mask must have the same height and width as the image. If mask is omitted, all pure white pixels are treated as holes. patchmatch.patchmatch_available tells whether the native library could be loaded. The previous import path from patchmatch import patch_match keeps working.

C++ (see examples/cpp_example.cpp, build and run it with examples/cpp_example_run.sh):

#include "inpaint.h"

int main() {
    cv::Mat image = ...;
    cv::Mat mask = ...;

    auto metric = PatchSSDDistanceMetric(5);
    cv::Mat result = Inpainting(image, mask, &metric).run();
}

The library is built with CMake; PATCHMATCH_BUILD_EXAMPLES builds the example and PATCHMATCH_WITH_HIGHGUI enables the debug visualization of Inpainting::run.

Development

The project is managed with uv:

uv sync                        # create .venv, build the library, install dev deps
uv run pre-commit install      # enable ruff and the other hooks on commit
uv run pytest                  # run the test suite
uv run pytest -m "not e2e"     # only the fast unit tests

Releases are published to PyPI by creating a GitHub release; the version is taken from its tag (e.g. v1.1.0).

@Author: Younesse ANDAM

@Contact: younesse.andam@gmail.com

Description:

This project is a personal implementation of an algorithm called PATCHMATCH that restores missing areas in an image. The algorithm is presented in the following paper PatchMatch A Randomized Correspondence Algorithm for Structural Image Editing by C.Barnes, E.Shechtman, A.Finkelstein and Dan B.Goldman ACM Transactions on Graphics (Proc. SIGGRAPH), vol.28, aug-2009

For more information please refer to http://www.cs.princeton.edu/gfx/pubs/Barnes_2009_PAR/index.php

Copyright (c) 2010-2011

Requirements

To run the project you need to install Opencv library and link it to your project. Opencv can be download it here http://opencv.org/downloads.html

Release files for PyPatchMatch 2.0.0b1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PyPatchMatch 2.0.0b1
File Size Uploaded
pypatchmatch-2.0.0b1.tar.gz 449.7 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for PyPatchMatch 2.0.0b1
File
pypatchmatch-2.0.0b1-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
pypatchmatch-2.0.0b1-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
pypatchmatch-2.0.0b1-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64, Linux glibc 2.27+ ARM64 Details
pypatchmatch-2.0.0b1-py3-none-macosx_11_0_x86_64.whl Python 3 none macOS 11.0+ x86-64 Details
pypatchmatch-2.0.0b1-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details

Total release size: 5.1 MB

Release files / pypatchmatch-2.0.0b1.tar.gz

Download URL pypatchmatch-2.0.0b1.tar.gz
Size 449.7 kB
Tags Source
SHA-256 checksum
How to use checksums
92363b840d7ff27888791d6361d2bf1a543cff68c13fd550f9cdb97c5c7bff2d
BLAKE2b-256 checksum
How to use checksums
6e90f7ee689a9b1890b8dce159fe8047021afc940ca1ea4a20864d30681afcd6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / pypatchmatch-2.0.0b1-py3-none-win_amd64.whl

Download URL pypatchmatch-2.0.0b1-py3-none-win_amd64.whl
Size 361.4 kB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
7edf8f3c3c14665f8a9c2f2fafdf80599da3a38fa8ad3d78d4b0e0f8c384b3e7
BLAKE2b-256 checksum
How to use checksums
0f7ffc2561c98efb7a859a46960aef787f00f547e00ad14a8ccb264a882eafb4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / pypatchmatch-2.0.0b1-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL pypatchmatch-2.0.0b1-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 1.1 MB
Tags Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
94aede644a3548272f3e443944478d50d2bff2fa3ff79141591ef72888504db5
BLAKE2b-256 checksum
How to use checksums
d88713eab4e10792bd912c681e16865155b7adc48ea78f1e6ccd477fbae740a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / pypatchmatch-2.0.0b1-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl

Download URL pypatchmatch-2.0.0b1-py3-none-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Size 1.2 MB
Tags Linux glibc 2.27+ ARM64 Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
b7e5d441eb769583b07a2ec883d5a0cdbb03c9322cd9d3a5e2fd28da98ca4b61
BLAKE2b-256 checksum
How to use checksums
cf519c831830be90e7948b84b45b88a5922ba20f9c56e94f914a20822fc40ce0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / pypatchmatch-2.0.0b1-py3-none-macosx_11_0_x86_64.whl

Download URL pypatchmatch-2.0.0b1-py3-none-macosx_11_0_x86_64.whl
Size 929.8 kB
Tags Python 3 macOS 11.0+ x86-64
SHA-256 checksum
How to use checksums
35a1c279921d546c4cfbf61d17ce0c921230e817e91f46bc81a9bee71f356e0d
BLAKE2b-256 checksum
How to use checksums
8634312824a2075fbe027f4b3631d137bd8b14233a67886ba0bbc27ecbc7d67d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log

Release files / pypatchmatch-2.0.0b1-py3-none-macosx_11_0_arm64.whl

Download URL pypatchmatch-2.0.0b1-py3-none-macosx_11_0_arm64.whl
Size 1.1 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b9de6c63e28bd3b449e29d58b92b6739c03d770fe1cbe8841ba5c34797c2aca4
BLAKE2b-256 checksum
How to use checksums
22fb7074c523ab731f806e0e6bbdf6dcc72c655291019b05257d6acc84f93664
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page