Metadata-Version: 2.4
Name: pocpy
Version: 0.3.0
Summary: Phase Only Correlation in Python
Keywords: registration,phase-only-correlation
Author: Daisuke Kobayashi
Author-email: Daisuke Kobayashi <daisuke@daisukekobayashi.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering :: Image Processing
Requires-Dist: numpy
Requires-Dist: scipy>=1.4
Requires-Dist: opencv-python>=3.4
Requires-Python: >=3.10
Project-URL: Homepage, https://github.com/daisukekobayashi/pocpy
Description-Content-Type: text/markdown

# pocpy (Phase Only Correlation in Python)

This repository contains implementations of phase only correlation and rotation invariant phase only correlation in python.

## Installing pocpy

```console
$ pip install pocpy
```

## Usage

```python
import cv2
import numpy as np

import pocpy

f = cv2.imread("reference.png", cv2.IMREAD_GRAYSCALE).astype(np.float64)
g = cv2.imread("target.png", cv2.IMREAD_GRAYSCALE).astype(np.float64)

# translation only
peak, dy, dx = pocpy.poc(f, g)

# translation, rotation and scale
peak, dy, dx, angle, scale = pocpy.ripoc(f, g)
```

- `f` and `g` are 2D arrays of the same shape.
- `poc` returns the sub-pixel translation `(dy, dx)` of `g` relative to `f`.
- `ripoc` assumes `g` is `f` translated by `(dy, dx)` and then rotated by
  `angle` degrees (counter-clockwise, as in `cv2.getRotationMatrix2D`) and
  scaled by `scale` about the image center.
- `peak` is the height of the correlation peak and can be used as a
  similarity measure.
- Rotation is estimated within ±90 degrees, because the amplitude spectrum
  used by `ripoc` cannot distinguish `angle` from `angle ± 180`.

## Development

```console
$ uv sync
$ uv run pytest
$ uv run ruff check .
$ uv run ruff format --check .
```
