quat_correlate — QUAT match op

数据种类:qimage × qimageqimage

调用:import quatimage; quatimage.quat_correlate(qimage, template) -> 'np.ndarray'(或 opsquat.get("quat_correlate"))

用法

四元数互相关 `sum_s conj(a(s)) * b(s+t)`。→ (H, W, 4)。

> 以下的详细说明为原文 —— 摘要与标题已翻译。

Colour template matching that keeps the colour geometry, not just the

colour magnitude. The scalar part of the result is

`sum (a_R b_R + a_G b_G + a_B b_B)` — exactly the sum of the three

per-channel correlations, i.e. what a channelwise pipeline computes and all

it computes. The *vector* part is `-sum (a x b)`, the accumulated colour

cross-product, and it is zero exactly when the two colour fields are

parallel. So the same call answers "how well does it match?" (scalar part)

and "in what way does the colour fail to line up?" (vector part).

Measured on a 32x32 patch whose colours lie in the red-green plane, matched

against a copy of itself rotated about the blue axis. The scalar part is

`cos(angle)` times the self-correlation, exactly, and

`atan2(|vector|, scalar)` returns the rotation angle:

=========== ================== ================= ==================

rotation scalar/self ratio `cos(angle)` angle recovered

=========== ================== ================= ==================

0 deg 1.000000 1.000000 0.000000 deg

30 deg 0.866025 0.866025 30.000000 deg

90 deg 0.000000 0.000000 90.000000 deg

=========== ================== ================= ==================

with the vector direction at `(0.000, 0.000, -1.000)` — the negative of

the rotation axis, because the conjugate sits on the left of the product. A

channelwise pipeline has no term that can produce any of that: the

cross-products are *cross*-channel products, and three independent channel

correlations never form them. (Verified in the same test: the scalar part

equals the summed per-channel correlation to 0.0 exactly, so the channelwise

baseline recovers the scalar part and nothing else.)

**The exact reading needs the colours to lie in the plane orthogonal to the

rotation axis, and the docstring says so because the general case is

biased.** For a colour field with a component along the axis, the vector part

picks up terms in `a_z` and the recovered angle is wrong: measured on a

uniform-random colour patch rotated 30 degrees about blue, the same formula

returns 22.524 degrees on an axis of `(0.247, 0.419, -0.874)` instead

of `(0, 0, -1)`. That is a quiet wrong number, it is inherent to summing

per-pixel cross products, and it is not detectable from the result — so the

precondition is part of the contract.

Both inputs must be pure quaternion images for any of the above to hold; a

non-zero scalar part is not refused (it is algebraically fine) but it

contributes to both parts and the colour interpretation stops applying.

The correlation is circular (computed with FFTs, like

`filters_freq`'s family): a template near the border wraps around. Pad the

inputs if that matters. Shapes must match exactly; a smaller template must be

zero-padded into the image's shape by the caller, because silently choosing

a padding origin would move the peak.

Raises `ValueError: either input is not a valid (H, W, 4)` field,

or the two shapes differ.

详细使用指南

quaternion_monogenic 族使用指南

参考(示例数据・文献)

• 示例数据目录(下载 URL / 许可证) —— 2-D 用 skimage.data(BSD/公有领域)加合成图,3-D 给出真实数据源(Stanford/PDS 等)的下载 URL。

• 算子来历与参考文献 —— 该算子族所依据的研究/方法出处。

• 算法的正典(作者・年份)与用途见上面的族使用指南

可运行的示例(实际调用该算子并已验证的样例)

quaternion_monogenicpy -3.11 examples/quaternion_monogenic.py

类型可衔接的下一个算子(可接受 qimage 作为输入)

quaternion_to_rgb · quat_norm · quat_conjugate_image · quat_normalize_image · quat_image_multiply · monogenic_amplitude · monogenic_phase · monogenic_orientation

同类别(match)


*Provenance: quatimage.py — QUAT 算子登记表。本条目由 tools/opdocs.py md 自动生成(请勿手工编辑)。*

© 2026 Kazufumi Furuse — Fullseye operator documentation. Licensed under Apache-2.0.