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.4.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.4-cp313-cp313-win_amd64.whl (284.2 kB view details)

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13Windows x86

patchmatch_cython-0.1.4-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.4-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.4-cp313-cp313-macosx_11_0_arm64.whl (288.0 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

patchmatch_cython-0.1.4-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.4-cp312-cp312-win_amd64.whl (284.4 kB view details)

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12Windows x86

patchmatch_cython-0.1.4-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.4-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.4-cp312-cp312-macosx_11_0_arm64.whl (289.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

patchmatch_cython-0.1.4-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.4-cp311-cp311-win_amd64.whl (284.6 kB view details)

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11Windows x86

patchmatch_cython-0.1.4-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.4-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.4-cp311-cp311-macosx_11_0_arm64.whl (289.8 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

patchmatch_cython-0.1.4-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.4-cp310-cp310-win_amd64.whl (284.9 kB view details)

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10Windows x86

patchmatch_cython-0.1.4-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.4-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.4-cp310-cp310-macosx_11_0_arm64.whl (289.7 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

patchmatch_cython-0.1.4-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.4.tar.gz.

File metadata

  • Download URL: patchmatch_cython-0.1.4.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.4.tar.gz
Algorithm Hash digest
SHA256 58bcaf4eaa4da271354573216a32d7b6d2c6ad3a43da196852d5230c441d5857
MD5 81cd933f946f0aeb4f8e29ec44808592
BLAKE2b-256 2726e127775dd0de73d5207655d1f9fa2c649d0ace45124901817ff30180d6da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 68fa9245c9453b8126af37ad4a0931bf3996280a3d80fbddc340ac7ffcb680d4
MD5 1441387d74a5b7910b8c45b485cb407e
BLAKE2b-256 622b8808df1c7a385e161ec079daca56a42295047e578bd74344c248df68ff15

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.4-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 1ea944c4d35fb44894a2a905891c7991b5dde8e9858259556fd1566198db8120
MD5 b45e0ff12df089009aba1965f44f077b
BLAKE2b-256 ec0625e2836ea51635ac5d913a5bb1c5a4df07ebd98ab4d1e702cd13d62f5547

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.4-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 578ae7ec13f04eec375301c78f8b6bdfc548ded1489e9435633671a1fc3ffc56
MD5 488cdff719a2142aad6217ecc1304ffe
BLAKE2b-256 736e6d78b8410fe91a59224a11cf46c65ba7a2e3fc545710ac81bbc21ea40546

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.4-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.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a669ef2a7874b593b4f668142f10f20e255843ed72fe650137802b8dc175885a
MD5 1508b67669387eb0ee22b3994c82a29a
BLAKE2b-256 31080de8e13b98e7d0108c181d7c8d051a1edaf8435907533f7e7fc0950464c5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 035b5c13ea7a874e8b09ed1783a8dcad032b0645087398573394a51e5ddf862a
MD5 324eb0a839eee104c3f1fa3597013d89
BLAKE2b-256 28214484edcb470d713c84b098f1c89a3abd3e3a03eecab03d5f34a41ab945cd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.4-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 065f12989ae3b13ffca24ff0a2780f0318008300a9261e275d836d6e5543996d
MD5 27c8e41c35bd79d2b4393d3e708598e0
BLAKE2b-256 45bf71ff56a5a194c57f6d3bd9a503aceefcea9396377eff1f7588584f4b1b58

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 8d52c6106668c943866362ca1777bd814ff528cceec5e47b13a3e6bc093f33af
MD5 7769bf7638956eb79491247ec2284af8
BLAKE2b-256 d4ab2f3e6d7be58089a9d9bbbf94dae4858b12c343ce65ad0bc906d7ec56cac9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.4-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 c5044141d4cb7514b90ac11e9afb98df70976b2de2e53714eec98bc14190d57b
MD5 e4387da63b0b6aedce0ea0f0ed7b9923
BLAKE2b-256 c361d6791b6849da4571df9b868a33c8545f9b8d48170a2eefc82161284730a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.4-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e3928da5bad58ba9fe987ae7b7c9f0270499882811da1b6f43346a10903397a0
MD5 604c3a2bfc0e7bdc7e51eca185de20e2
BLAKE2b-256 dbb887678d1773d81aa985df374b649eeafc8f1c1be96fffd2c8a092e3b1ebc9

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.4-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.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b55692f2e28d2063b2350cb1f2bc2391397e8c9dbed3af13a0a7e7f1f4e412ac
MD5 efeb784df0a93435c54de923939b5367
BLAKE2b-256 a678a3975b6084e17d130319858a6d0e37c7bfa635ae6d73903aa1409c7ead2c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3120335b235f59198905952e30110ba35838a03c27ab310bf7a783b3baaa23c6
MD5 dbf573d3a5e8e38281237a606529bedf
BLAKE2b-256 b2d522a8244215ec9e92268984576e80705efcb2626f663b8c344f24459b0bca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.4-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 54a018400c17bdbd18f11a7066a32940bd85ebeb2d291a870907c6d5808d11ef
MD5 93735b132190520bf717ece4f16f148a
BLAKE2b-256 57428a522b5ace75bbcb96749c44dfad079815b011cf5c40375b5c41dbe4d554

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3748ded18d301528910c8d8db0de4e339b9afba5a21fcfc18736505bb29378a7
MD5 0bf95f2c2c355b38d387639e62a97ff4
BLAKE2b-256 084abf0f94daa60a9b9592f02d54fc2e443353200d5b4abb4440ec9b6716bf57

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.4-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 e276d6d282bd53418a3da535c65bcb130428b0b1cf39779c412e691336eacde1
MD5 7b7c4786460cd2d21910992dbc4990bc
BLAKE2b-256 0953f12c032f3f6be5f3e075d5d35067969dffb66a0fe45b5035e3d384cb9556

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.4-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 6ae5e0b1aa2322929c23cc2cf308a72e28c7c8d7bce1c217eb09d6e1681dcb35
MD5 8d69ade3ddde16ecd8dc0e081c1f7230
BLAKE2b-256 6e3cd6bfaba3a377770b09618b012a0fd0a48731e96667dea1e12b5d610d8f58

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.4-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.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f068926ef9b69a9159ce3d5936dae23556e6fddddaf0bbd1086418da8bbf327f
MD5 bd63517073084e4c60b7fd1bed7ae446
BLAKE2b-256 20ca1609262c28f09ee0aad7aadb655ead6f140aefca9bd505b60b89ff0ca7f2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 68b2650dceb07f75f66e46c58b77a965b6d7c42df1445e46552985b0897acb70
MD5 70204c44c5dedb8450e67aee32df6ac3
BLAKE2b-256 055b2b088c80b82cddb480c379b6dfe402ffd5e432fbff9b9cf725effc80c6d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.4-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6ec9edcfe4145fd7e63658eb6c22969d5033a5ee8991533bccc54257589a0823
MD5 76a109f1f75319da3e469e1aee8cc9e7
BLAKE2b-256 a41fc54edbc310d6e89cdeddb29dcd801b044761ae7141b66de8334e29e8aff6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e52bfe68e72ad130ed744f03fc40df5876320bedd482d7012b026a682a78fd69
MD5 cfdb49636030050c98124fcb5434ebbb
BLAKE2b-256 b534e4f43e2ddd66f273160dc2abbe8dc00ef12fedb8fa574ed888cc35fb342f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.4-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 ee887120db4729584be2ff04f8e3e83f0210dc4ae23a72b76f8981e1bc2a9246
MD5 c58dfbe2c5e80ad5d978559dc279080c
BLAKE2b-256 e998ddefe938713de6f217b13df58753b24ae0cbfc373544876805072a795548

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.4-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e84309b7b827e998688f2567a5f20f23ddde1fc13016e9053b4217fb0b85b8bd
MD5 ca8f76bf66334384ed18b6a3b5c6ab2c
BLAKE2b-256 092c59355ffd93ec992ce3ccb3c2c642a9866140bc48c7c7db2c47d79a143b60

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.4-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.4-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 58b17b0650797c58c4d8436437b3d4674253c856982f809a4a8a34b36f3b85ee
MD5 aaa9b1718f481ee8b38dfdcedcf4dbdc
BLAKE2b-256 9c14913e229a6272086da561553b620bd617b7c1372ab2d3b3f507ffc3731262

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9dc56c1ca3b122fb2764167b981a73ad1caf828d120347b7f47cd7081f9c706a
MD5 86ee294673d0c731cf214f0d09c272eb
BLAKE2b-256 a3a67dde02f8dd4161383da1a8ebae0b9a97e7a45bdd89772d5b035c2ac73597

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.4-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 38de51b393da0cd9f1a7c35a34a13c3051a7c6d7385fb698a7b2390be8518591
MD5 6580cce56168f1bf6d1d79575620b2f0
BLAKE2b-256 c2194103b8739188e73cb43ad2e22c8bf211ede8706f56f9f830ae1f82ef1474

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