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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13Windows x86

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12Windows x86

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11Windows x86

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10Windows x86

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

Uploaded CPython 3.10macOS 11.0+ ARM64

patchmatch_cython-0.1.0-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.0.tar.gz.

File metadata

  • Download URL: patchmatch_cython-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 735c05973a6434eb3f58e08ddde6abba6bf0f8456f1a126c9a923d43ed8e12fc
MD5 25f947844cd1a4d72cc0e096b404c8b6
BLAKE2b-256 7226093342c8d41c8c2cdf984436b2d9715fc1bc1a3dfa7db47ebb23e7a0ec4a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 38790aed3e37b5811e6b22196b159f1c43224254ca499e87ea79a397c9829331
MD5 3e5be5efd32a9bc6bf5b4a58b0e9bcfa
BLAKE2b-256 7f47ef7185a90fa16633ccd4bf21838bc8f047d3e1dedb37128a76e95711d31b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.0-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 cf4e0ca508a30ebc0790f02126a777a6d555f572a85b360a1333e1b1116b1f08
MD5 0e44a76543131c8ed346d9e7f18c2664
BLAKE2b-256 9ed5aa0a2fb3486e7f9a823e7ae40cad546fc6cfe7d5c4c24bcce12f7b4f5a78

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.0-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 0fd12a46680a6e5e4aca5a5623f74a487f3678be3ddcfa9f169a04f0b201e280
MD5 10f9a5a6bc831d2473b49b9c341f8089
BLAKE2b-256 681d7229687e0880c5f50b44b6f28f81505a7e43dcbd1956e653f53af0755bdb

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.0-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.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e236fb7a5bc4ccb41fb60998d5adb25e3c597da53ce1f55af915dc81c35c9cfc
MD5 29e9727456630657e06fc30b6b0c4c02
BLAKE2b-256 60d6bfa2fc5145bba656f8226ad3c4aca3e8d650917720fc25c3cf258190a1d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d7c75ac823af98ac0304dffe3313fe87f6392493714a3f64fb6d0f0cb651dadc
MD5 f9237f892fe16fbdffd68c0798d7bca3
BLAKE2b-256 efde7adc5835f71d85aaae616e372899b6ecfc6dba49081850e5830cfec50e0f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.0-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 a5a089d6046b652dfc84d423e6e2551928b5ff6b6aa49987874778d4996affea
MD5 874a8dacb00f6cf3d6f09ce547e7a3fc
BLAKE2b-256 79201f28d0d2593565acd0b067e1d8819e2094370bdd03001d0971ada16e6e4b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b4b946dbed36bf2fe290d9be7d22cacef836ba0d2e3d9720d5c02e0ffaf372be
MD5 ba5af12fa27d84b472b409ebc112813b
BLAKE2b-256 bf3fc6059fb8f94890752ce76a062966cb66aa0ca47ccad2ec3abf345ea346d2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.0-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 ec08f25ef00ffcf0bf81e29ba4504022852e9fc88fa3f6516e84256d49bd5273
MD5 bfdffd738f764da9417f271fe26295b0
BLAKE2b-256 f9df47332c203b1703b8ccb12faf81f871c84573f883aa269950b151c72701c6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e4c48dccd92144b31f824719e981f1ceed85ccaa743e2af2e02779b9031b3a2d
MD5 efdd6a5922fef965deaef5163e405515
BLAKE2b-256 085600165f5585fcb1840c01b350ce4304bc9a880502bd36fad337468c51639c

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.0-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.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 10ce808972824067d0d75a312e64a3a0ac9dfd7e8843f74f716ce12be4db316c
MD5 01a27d692e03e61d0b6ce54cd4faa9f1
BLAKE2b-256 f7a06cc8e280c34dd3297ed20390770947d13c05367a02afa57c03e1ea4c9ac2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 624851927efc83536f4c7792583a7590f4e489012f34eaa6cfef212fea4b2ffe
MD5 5e4b3a2a816c8d64c5469ac9f095c3da
BLAKE2b-256 bcbde317282f131585280fbd1e0f4a4c0d18d9a59b642112b900b918d3a2691f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.0-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 e4912526d2646807d91e64a857990d8409dff1f3a5f1d7632bc30c0f48ac0b9b
MD5 5eda4626ea046b1682448151ebf4f6fa
BLAKE2b-256 3342cdb6cd27f68d26803570d9d34b1210c00908a57968032566804299f86c3a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 5b6c0cc30523dafe5b2f81a3809db7874e250a7d382be29e9f116996b7af3fa9
MD5 7141ab049f49a19e53cfebcf7f81a231
BLAKE2b-256 758d4825c7fbd675c33c2f68c5c798d2b8ba2248259801e5396a6b5ed60aa116

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.0-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 710ed1eef7c640ee390a8dd6cb9ca8e5ac6fb0d5a698e075098f555619817fc5
MD5 2016a5e356fe4ec0bd5085e3498fb920
BLAKE2b-256 d88c92f0214afaa3f69ce2de6e292574e6cb46796d5925c52add09ad546ac71a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.0-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ed5bb49e5132ad392bad5dffec17308738ad1897440bf5759589365c591e91a9
MD5 dafc381c9774f91d2c42097574060fd1
BLAKE2b-256 c03df85066312b99293ca5b6b4dd239deb096442002765ef80fd225352ec2aa4

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.0-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.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5b800a3e447ef824ff58c05c49589c6db778e9740fcb1f61f1d0a06e945bf539
MD5 aedb3ef24eaf6b0cf7e840cfced40708
BLAKE2b-256 dc5b65553a6dd1dbe22d7271b4f06f8931057e496cb4a1c67ac580f4f2293cef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 59ed6f7a252c4c33eab8dbab9701c09d965a0b83fcd657957922691e95a38f11
MD5 6fb9a0efd4b412a1a50bc62bf9014553
BLAKE2b-256 f3184cae0abaff7348625620b2c343f935ebbad7a693d3b437d9e021d8a11a0f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 72a14a628bb2909a4cf3115f3b073c634afe12aad208d5fb460b3a65ca07b078
MD5 3e1230d23641424149b196d49fb9774a
BLAKE2b-256 3c5a2cb30d7990c786ae6b600ad0f14bffb6781d0aad48e48c724c61bd9aa467

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 83822387172dc560518dcb8d02d2148eaf43cff41b0045fe9c0a2acb603a958f
MD5 e4d688ce4179d70b6bd892742f8374dc
BLAKE2b-256 9178fe8b5b4624bd500d79d439c2670a09bf7566bffbf4f6b9dc71472f97e945

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.0-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 7b93f929d5d66329af4fd3de5124a279a6e319d21f2d131581ffeae889d30c42
MD5 d2047f2351cb5f051e1bdf33dd9ce22d
BLAKE2b-256 211a8cc378938b5162b6e9bff6d8de90d991cf2e7c9ec95c7406424e5b0f5da6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.0-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 cd95811e6762a5365effbb0940b9d212f1e9cd5db8c3caddd705c6c87bf0d49b
MD5 19d3001f7e6f6b9649a74f3aa26a38fc
BLAKE2b-256 5da34d4fc07283cd5a3dd6160e685fb67d671725192843c32ef7c606f0772109

See more details on using hashes here.

File details

Details for the file patchmatch_cython-0.1.0-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.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 922f8c0a891278f586acc6d87c6baf285ed0b40fe780cbb63709db162b810aee
MD5 1e34bb22e23ec7695d67134bd5aaa7ff
BLAKE2b-256 75e975d9bb06b4b031ff7001572becaeebe36553edc724f917508b6a94384326

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 34d071cd6450dec05530921b713a9afce7326fac2cf92f42269600ce29dba3eb
MD5 28e02f34e48c222f68c92ff9732067f2
BLAKE2b-256 6f0b1b819d154591ef40731c1d91fa5ec09a80486cc245a44b7d04d798c1a5ca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for patchmatch_cython-0.1.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9511daba5de31cccba4f1a881b1b292ea8ce183ce34351697a958f85075477d2
MD5 078130fc6417bbf3b5c3c1f4a0afddcf
BLAKE2b-256 b3587a982523f8540b18d121c130dde214e21b7357a471f5eeb1f25a215693b9

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