Maximum clique for 2D or 3D points
Project description
Spatial Clique
Applies the concept of a maximum clique to two sets of corresponding 2D or 3D points in order to find the largest group of points whose relative positions are the same in both sets. Sameness is defined via either a hard threshold (a Euclidean distance) or a soft threshold (a confidence level) applied to the differences between the intra-set distances. Soft thresholds require point covariance information.
The point sets can be thought of as "source" and "destination" in the sense that the "source" point set has been subjected to some type of transformation or deformation to produce the "destination" point set. The maximum clique will identify the largest group of points that exists in both point sets and differs by only a 6-parameter rigid-body transformation (translation and rotation). It cannot handle scale. Alternatively, the "source" and "destination" point sets could be putative correspondences, perhaps determined by a nearest neighbor metric in a descriptive feature space, generated from data obtained from two different observations of a common spatial scene.
The current implementation emphasizes clarity (for the creator, at least) and is deliberately inefficient. There are multiple nested for
loops that could be replaced with more efficient mechanisms, e.g., scipy's cdist
function could be used to compute all intra-point set distances.
Installation
- Source: clone the repo and
pip install .
- PyPI:
pip install spatialclique
- Conda: perhaps in the future
Usage
Not much to see here:
from spatialclique import mc_hard
max_clique_indices = mc_hard(src, dst, 0.2)
Of course, you must create the (M, 2) or (M, 3) sized src
and dst
arrays of 2D or 3D points first. The distance threshold is set to 0.2 in this example.
For a soft threshold, you also need (M, 2, 2) or (M, 3, 3) sized arrays of covariance matrices (one for each point in the src
and dst
arrays):
from spatialclique import mc_soft
max_clique_indices = mc_soft(src, dst, src_cov, dst_cov, 95)
Here, we have set the confidence level to 95%. The covariance data is propagated through the distance and difference computations, and only those differences statistically equal to zero (at 95% confidence in this example) are included in the adjacency matrix that is fed to the maximum clique algorithm.
Reference
None of this make sense? This reference might help:
A. Parra, T. Chin, F. Neumann, T. Friedrich, and M. Katzmann, “A Practical Maximum Clique Algorithm for matching with Pairwise Constraints,” arXiv:1902.01534v2 [cs.CV], Feb. 2020.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file spatialclique-0.1.tar.gz
.
File metadata
- Download URL: spatialclique-0.1.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f120b9955f46fc058dc6070f684a631bbba205b1566c1401a58370f8fc3f1931 |
|
MD5 | ec8c84e70b81cfa544eb2e13735a4023 |
|
BLAKE2b-256 | a50143f4a40ad67c8d9be872bd85213af7fc9249dda5ba1814726215b495de69 |
File details
Details for the file spatialclique-0.1-py3-none-any.whl
.
File metadata
- Download URL: spatialclique-0.1-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed4458e8f4a34c3746bada7bde89dcc03b700d4063dde5a56f7b5be73a5b431b |
|
MD5 | 9d24ec03043c8ae7577b48ab879dac2f |
|
BLAKE2b-256 | 7fa39576b779cac658e5029f1500e5f44307cde57c89dabe1fb23afb25d9506c |