Metadata-Version: 2.4
Name: patchmatch-cython
Version: 0.1.3
Summary: High-performance PatchMatch implementation for image inpainting using Cython
Home-page: https://github.com/Teriks/patchmatch-cython
Author: Teriks
Author-email: Teriks <Teriks999@gmail.com>
License: BSD 3-Clause License
        
        Copyright (c) 2025, Teriks
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Project-URL: Homepage, https://github.com/Teriks/patchmatch-cython
Project-URL: Repository, https://github.com/Teriks/patchmatch-cython
Project-URL: Issues, https://github.com/Teriks/patchmatch-cython/issues
Keywords: image-processing,inpainting,patchmatch,cython,computer-vision
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Cython
Classifier: Topic :: Scientific/Engineering :: Image Processing
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.21.0
Provides-Extra: visualization
Requires-Dist: matplotlib>=3.5.0; extra == "visualization"
Requires-Dist: Pillow>=8.0.0; extra == "visualization"
Provides-Extra: dev
Requires-Dist: pytest>=6.0.0; extra == "dev"
Requires-Dist: build>=0.8.0; extra == "dev"
Requires-Dist: setuptools>=61.0; extra == "dev"
Requires-Dist: wheel; extra == "dev"
Requires-Dist: Cython>=0.29.0; extra == "dev"
Dynamic: author
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

# 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

```bash
pip install patchmatch-cython
```

**From source:**
```bash
git clone <repository-url>
cd patchmatch-cython
pip install .
```

## Usage

### With OpenCV

```python
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

```python
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

```python
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:**

```bash
pip install patchmatch-cython[visualization]
```

Adds: `matplotlib`, `Pillow`

**For development:**

```bash
pip install patchmatch-cython[dev]
```

Adds: `pytest`, `build`, `cibuildwheel`, `setuptools`, `wheel`

## Building

To build wheels locally for distribution or development:

### Prerequisites

Install build dependencies:

```bash
pip install cibuildwheel
```

### Build Wheels

Use the included `local_build.py` script to build locally:

```bash
# 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)
