Skip to main content

High-performance PatchMatch implementation for image inpainting using Cython

Project description

PatchMatch Cython

High-performance PatchMatch implementation for pyramidical image inpainting in cython.

This package can function without python-opencv / python-opencv-headless with only slightly reduced quality.

Installing OpenCV results in this packaging using it for upsampling (INTER_LINEAR).

When OpenCV is not installed, an implementation of bilinear upscaling using numpy will be used.

This package provides a pure python solver and a cython solver, the cython solver is around 30 to 50 times faster than the python solver depending on patch size.

Installation

pip install patchmatch-cython

From source:

git clone <repository-url>
cd patchmatch-cython
pip install .

Usage

With OpenCV

import cv2
from patchmatch_cython import inpaint_pyramid

# Load image and mask
image = cv2.imread('image.jpg')
mask = cv2.imread('mask.png', 0) > 128

# Inpaint
result = inpaint_pyramid(image, mask)

cv2.imwrite('result.jpg', result)

With Pillow

import numpy as np
from PIL import Image
from patchmatch_cython import inpaint_pyramid

# Load image and mask  
image = np.array(Image.open('image.jpg'))
mask = np.array(Image.open('mask.png').convert('L')) > 128

# Inpaint (auto-selects fastest available solver)
result = inpaint_pyramid(image, mask)

Image.fromarray(result).save('result.jpg')

Explicit Solver Selection

from patchmatch_cython import PythonSolver, CythonSolver, inpaint_pyramid

# Force specific solver
result = inpaint_pyramid(image, mask, solver_class=CythonSolver)  # Fast
result = inpaint_pyramid(image, mask, solver_class=PythonSolver)  # Fallback

Package Extras

For examples:

pip install patchmatch-cython[visualization]

Adds: matplotlib, Pillow

For development:

pip install patchmatch-cython[dev]

Adds: pytest, build, cibuildwheel, setuptools, wheel

Building

To build wheels locally for distribution or development:

Prerequisites

Install build dependencies:

pip install cibuildwheel

Build Wheels

Use the included local_build.py script to build locally:

# Build for all supported Python versions (3.10-3.13)
python local_build.py

# Build for specific Python versions
python local_build.py --python 3.11 3.12

# Build for specific platform
python local_build.py --platform linux

# Build and test wheel installation
python local_build.py --test

# Build without cleaning previous artifacts
python local_build.py --no-clean

# View all options
python local_build.py --help

Build Options

  • --python: Specify Python versions to build for (e.g., 3.11 3.12)
  • --platform: Target platform (auto, linux, macos, windows)
  • --test: Test wheel installation after building
  • --no-clean: Skip cleaning build artifacts before building

Requirements

  • Python 3.10+
  • NumPy (auto-installed)
  • C++ compiler (for building from source)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

patchmatch_cython-0.1.3.tar.gz (197.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

patchmatch_cython-0.1.3-cp313-cp313-win_amd64.whl (284.2 kB view details)

Uploaded CPython 3.13Windows x86-64

patchmatch_cython-0.1.3-cp313-cp313-win32.whl (267.8 kB view details)

Uploaded CPython 3.13Windows x86

patchmatch_cython-0.1.3-cp313-cp313-musllinux_1_2_x86_64.whl (841.1 kB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

patchmatch_cython-0.1.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (845.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

patchmatch_cython-0.1.3-cp313-cp313-macosx_11_0_arm64.whl (288.0 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

patchmatch_cython-0.1.3-cp313-cp313-macosx_10_13_x86_64.whl (294.1 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

patchmatch_cython-0.1.3-cp312-cp312-win_amd64.whl (284.4 kB view details)

Uploaded CPython 3.12Windows x86-64

patchmatch_cython-0.1.3-cp312-cp312-win32.whl (268.0 kB view details)

Uploaded CPython 3.12Windows x86

patchmatch_cython-0.1.3-cp312-cp312-musllinux_1_2_x86_64.whl (851.4 kB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

patchmatch_cython-0.1.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (853.8 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

patchmatch_cython-0.1.3-cp312-cp312-macosx_11_0_arm64.whl (289.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

patchmatch_cython-0.1.3-cp312-cp312-macosx_10_13_x86_64.whl (295.6 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

patchmatch_cython-0.1.3-cp311-cp311-win_amd64.whl (284.6 kB view details)

Uploaded CPython 3.11Windows x86-64

patchmatch_cython-0.1.3-cp311-cp311-win32.whl (268.6 kB view details)

Uploaded CPython 3.11Windows x86

patchmatch_cython-0.1.3-cp311-cp311-musllinux_1_2_x86_64.whl (848.2 kB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

patchmatch_cython-0.1.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (844.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

patchmatch_cython-0.1.3-cp311-cp311-macosx_11_0_arm64.whl (289.8 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

patchmatch_cython-0.1.3-cp311-cp311-macosx_10_9_x86_64.whl (296.2 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

patchmatch_cython-0.1.3-cp310-cp310-win_amd64.whl (284.9 kB view details)

Uploaded CPython 3.10Windows x86-64

patchmatch_cython-0.1.3-cp310-cp310-win32.whl (269.0 kB view details)

Uploaded CPython 3.10Windows x86

patchmatch_cython-0.1.3-cp310-cp310-musllinux_1_2_x86_64.whl (820.9 kB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

patchmatch_cython-0.1.3-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (819.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

patchmatch_cython-0.1.3-cp310-cp310-macosx_11_0_arm64.whl (289.7 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

patchmatch_cython-0.1.3-cp310-cp310-macosx_10_9_x86_64.whl (296.4 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

File details

Details for the file patchmatch_cython-0.1.3.tar.gz.

File metadata

  • Download URL: patchmatch_cython-0.1.3.tar.gz
  • Upload date:
  • Size: 197.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for patchmatch_cython-0.1.3.tar.gz
Algorithm Hash digest
SHA256 2fd8e1e95e3c5e6370f3569a4cf2621a17d50c3e23664eed6bcf768cceb7a358
MD5 a5a1580683fe805f28f8e374bf9baf2a
BLAKE2b-256 6ad6ca323308ed19c294ab8ca556e2358b4ddbf701ec3672648a98c2181d3cbb

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.3-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for patchmatch_cython-0.1.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 168896a5b417d84be763c9245945d7361adfa8d6d63f291a47bc98c223f27c91
MD5 cc86cbba4f1529c7b03e1c52a3a6f730
BLAKE2b-256 885a3a580940ac9d11b6458354a22652e85658f07775d6fa88e52cedb4707740

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.3-cp313-cp313-win32.whl.

File metadata

File hashes

Hashes for patchmatch_cython-0.1.3-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 d59bd36e0ce0b17af2c35d0a99b512b6a2cc49a42a794071644bbe64d8088534
MD5 f45a342a400ce5dde00f646fb963907a
BLAKE2b-256 144528bda1c8701bead83eb147ab894e6fc47d6bb042fa238a9503b15e0f216f

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.3-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for patchmatch_cython-0.1.3-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 17346c30cc941d58fc11a3ac4c60af4aa5c6833220bd392f9db12c457373b2ab
MD5 afc7793a379290ff0d79696421e7350a
BLAKE2b-256 fe726971bc016423bea746a70f14719c98baa051cc836548b202999e64f795f5

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for patchmatch_cython-0.1.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 39c6b38699eae6da6ffcb56143bc2d6aace84651066d4915c86600375a284180
MD5 be9af6681e97732d231204663ab6ef6b
BLAKE2b-256 5329e277a1527e5ac02095768e1e690428fb3a7469772c393f62990b0c58c03d

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.3-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for patchmatch_cython-0.1.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b9ed1e7c780107fd1fd553e1ad8e43b7179a54ceae9808abd7b1a3ed29cd73ba
MD5 b293cffa53dc6324571fd96d41131dde
BLAKE2b-256 140c8be65f5c43da2919d47fed5cdf341f5b4dff738d8a21b5ee5858811bbeb9

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.3-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for patchmatch_cython-0.1.3-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 61086bc640e420bb511b646c05a688bad969d7dc3da056b998a021347cdd3a2e
MD5 5f5e97f2a4d8f51efed31be87424775b
BLAKE2b-256 688df7ee2259b3805a57533c96359b11d2c35718afdc49ff2716f7efa02b8c06

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.3-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for patchmatch_cython-0.1.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9a9d04a18ee782641aa8bf0021c635869cddf53ac29b742b0b39fa7560a97236
MD5 289d9a896395688b53a8447494acc9d7
BLAKE2b-256 d779dbd0775653d88c4a78317cc2a143d6550e360ba0ebf47b7fddb176291c95

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.3-cp312-cp312-win32.whl.

File metadata

File hashes

Hashes for patchmatch_cython-0.1.3-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 0e9875884ceb218d69c458748a1e9906b69ed31a63ddaffe3ab70b3842f5bce9
MD5 397597f8853a746d3733a9367341b5a4
BLAKE2b-256 214d27326d951552ffaa1a27c16d2e05407cb208bc1c50778b3fbdfc21459658

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.3-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for patchmatch_cython-0.1.3-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2b5fc1a2baeafac511fdb8beddba0731e3b8daf75374c4a5109137e1f5da58f0
MD5 7c5e2f0036ebb624a371bbdd1b0261ae
BLAKE2b-256 6e7758902e8170f1e9059450ed6e9479b2a097707f006d7c08e3f13633586552

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for patchmatch_cython-0.1.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7c8d35c13955ba71e9979a62d4c43d6372fca494775f76098ef5121fd0ef86e3
MD5 d8859c5e1328803f265b8f0e8aec9905
BLAKE2b-256 20c830890b6146a014f546876cc18333ecd599492280a5954731be1161758ec8

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for patchmatch_cython-0.1.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c6eabb58586d3d276d1a765034bf78ecb338098d0b03039af63f370eca75d088
MD5 f61c6073debde329595f6f79d029f881
BLAKE2b-256 0df868cd8981b9c6b7c57512a214de6c78cddf2903645c686638cc4a2911f24b

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.3-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for patchmatch_cython-0.1.3-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 488a2f796e647fff84dfca8755b4cc1176e69bf23ef7ead2c2dea753a00174a6
MD5 82685ffda5844a5608a63f801a3d27d1
BLAKE2b-256 37e0f0354e2b80e729b93422b482f94845e11b10084643da994066e2d85d4dd0

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.3-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for patchmatch_cython-0.1.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 51a0db7d57ae24f370c208b111186e1dc8a928a8b1539b3dab85a2954a0c4dc8
MD5 5144507168666c4db2a93ad809f257d3
BLAKE2b-256 1e39516e8f45f16726c4d95b6246c5f35a040373f64de617808a57561b8d1dbd

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.3-cp311-cp311-win32.whl.

File metadata

File hashes

Hashes for patchmatch_cython-0.1.3-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 bc1cfe7c8b549bb813a1a7fc5b23c76b6a358a2fdc1880046d9677aafe518190
MD5 9a5ffef49f3e03cc89d7bdc9c8ccfaea
BLAKE2b-256 fdd00741a5777a96ba57f9d26d44c489075480de889eb8e1e9547ff47fb3be2d

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.3-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for patchmatch_cython-0.1.3-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 660bae5caa5992ff5b876463b4c15bb204b1d58f9cfd5d09f2e34869e76b0485
MD5 0df08d5280331c2060c31b1e76d9bd9c
BLAKE2b-256 137ae956e7948500e43e4cf891a77c288ff9b5beb33f98e88d1470d63bba775b

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for patchmatch_cython-0.1.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 dd41e7cd87dc13bfd29664b99f7a161705ae1a3ee98f67de1795b874f5d51115
MD5 2c8fc81e5363ed7c14151fda28a15964
BLAKE2b-256 35fbaf94c8d27af128cb7e2007e91d86631c48af7159fb90323ec01b668e54be

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.3-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for patchmatch_cython-0.1.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8f540baeded4fefeafc937d0d20ed84dd096047b95a739e262417ea6ca1041c4
MD5 ff49a57c210e347e2fa0a1867f3b2005
BLAKE2b-256 a2a08da2f26593df6528c4d7928034b37f69b85c709c9e8ea972b7f006b3db41

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.3-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for patchmatch_cython-0.1.3-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 762bdcd8233d5fb0e521399fdc9f269af9120c88100f47e5fc9164aab2e77e82
MD5 626975b6d2a9fc967ea56eccc4e651a4
BLAKE2b-256 9eea5dc1cdc91ea98213a02c2394d7df8ad3f492d464791940c27268118947df

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.3-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for patchmatch_cython-0.1.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 33c6e03ce30db25394229a2a71fea999175a71780e1d20d86baedb2909e1a65d
MD5 f9f3a67a2b26a64278311471d0aa5129
BLAKE2b-256 8cd875fcc9ae0fc23e8451f01962678344dd6f6638433995b219167f062be723

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.3-cp310-cp310-win32.whl.

File metadata

File hashes

Hashes for patchmatch_cython-0.1.3-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 395efcdcd2131bbd7eda6caaddc0738fcee3d9cad6d816b2b5b5b3cc6e0ac8f7
MD5 37c4a18c13f40ef951771004d6764703
BLAKE2b-256 9a0c23a6d7b334621da7b312b5c56f5c6c632e99530fc22e01d19fb4f339da53

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.3-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for patchmatch_cython-0.1.3-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9eaf82c6c8eff315850346583fbf83c19c62d1e7d119b464e78644ca2aa7566c
MD5 25d44e71771c58f6a24c9f4911068035
BLAKE2b-256 3da14481c4804baa2e35af5fa5a9e440f75866e2a997ebd9629bd6799723f90f

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.3-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for patchmatch_cython-0.1.3-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2275b266bda3f7d40f32fb3915ce77814c4c6be35c13c08b60711b5fe489e0f5
MD5 e979a2caf24bda2040677de19b81f1a6
BLAKE2b-256 c773a7101afa01fed1e8a484b5876937a2be33aad4e959163b8d475039588245

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.3-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for patchmatch_cython-0.1.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 20f2fef250053c2b0881c606e3de20e6ca5f93243cc402c8b301b6990fa3e774
MD5 a26160d83cd16683b5d6389a221e3341
BLAKE2b-256 9b77799fdc7f29248053294d583120dc1e333548f102230a7fd17655324d959b

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.3-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for patchmatch_cython-0.1.3-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 61e9a6836e05b81210f7865518ec450e001ecc5e101f6ee9edf0e6302a7dcedf
MD5 73dd7ee59d5d89f8b0333a061234f836
BLAKE2b-256 26a196b7d874401763a6a1cd12e06c6c167f595bbd745375799d99f004f578f4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page