A small, reusable toolkit for Fourier-domain image similarity and reference selection.
Project description
Fourier Image Similarity
fourier-image-similarity is a small Python toolkit for comparing images in the frequency domain. It is written as a reusable Fourier-feature pipeline rather than for any single application domain.
The package provides:
- grayscale image loading and resizing
- 2D FFT magnitude and phase extraction
- Fourier peak detection
- local peak statistics such as prominence and entropy
- representative reference-image selection
- similarity scoring against a reference set
It intentionally excludes segmentation, spatial descriptors, dimensionality reduction, and downstream classifiers.
Installation
pip install fourier-image-similarity
For local development:
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install -e .
CLI Usage
Use a fixed reference directory:
fourier-image-similarity \
--query-dir /path/to/query_images \
--reference-dir /path/to/reference_images \
--num-references 10
Select references automatically from a larger pool:
fourier-image-similarity \
--query-dir /path/to/query_images \
--reference-candidate-dir /path/to/reference_pool \
--num-references 10
The repository also includes a local wrapper:
python demo.py --help
Python Usage
from fourier_image_similarity.pipeline import run_similarity_analysis
rows, references = run_similarity_analysis(
query_dir="/path/to/query_images",
reference_dir="/path/to/reference_images",
num_references=10,
)
for row in rows[:5]:
print(row["file"], row["similarity_score"])
How It Works
Each image is converted into a compact frequency-domain description built from:
- FFT magnitude
- FFT phase
- prominent Fourier peaks
- local peak prominence
- local peak entropy
- local phase entropy
The final similarity score aggregates:
- peak match ratio
- peak mismatch ratio
- average nearest-peak distance
- mean prominence difference
- mean peak-entropy difference
- mean phase-entropy difference
Scores are normalized to [0, 1], where larger values indicate stronger agreement with the reference set.
Reference Selection
When more references are available than requested, the toolkit selects the most representative images using a frequency-only heuristic based on peak-pattern centrality.
Repository Layout
src/fourier_image_similarity/io.py: image discovery and preprocessingsrc/fourier_image_similarity/fourier.py: FFT magnitude and phase extractionsrc/fourier_image_similarity/peaks.py: peak detectionsrc/fourier_image_similarity/features.py: local peak statisticssrc/fourier_image_similarity/reference.py: reference selectionsrc/fourier_image_similarity/scoring.py: similarity scoringsrc/fourier_image_similarity/pipeline.py: high-level workflowsrc/fourier_image_similarity/cli.py: command-line entry point
Citation
If this package is useful in research, please cite the paper that motivated the extracted Fourier-domain workflow:
@article{SMITH2026100643,
title = {Mobile phone image-based framework for anti-copy pattern detection and classification},
journal = {Array},
volume = {29},
pages = {100643},
year = {2026},
issn = {2590-0056},
doi = {https://doi.org/10.1016/j.array.2025.100643},
author = {Joseph Smith and Zheming Zuo and Jonathan Stonehouse and Boguslaw Obara}
}
PyPI Readiness
This repository is already close to PyPI-ready:
- it uses a
src/layout - it has a
pyproject.toml - it exposes a console entry point
The remaining publication work is mostly packaging polish:
- choose the final repository URL and replace the placeholders in
pyproject.toml - confirm the license you want to publish under
- build with
python -m build - upload with
twine upload dist/*
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fourier_image_similarity-0.1.0.tar.gz.
File metadata
- Download URL: fourier_image_similarity-0.1.0.tar.gz
- Upload date:
- Size: 12.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74e3df70d6f60c83357021041a2a474b0be3482e81d99305efa60cd7c4df27ca
|
|
| MD5 |
2f7ed6ef7b4fcfde0f1fbedd5cad119b
|
|
| BLAKE2b-256 |
75efa0b92f3c89b4df618175cfa581f69196af3c61fe93b81342a72d538756d4
|
File details
Details for the file fourier_image_similarity-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fourier_image_similarity-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfde70ef97836e0810476c1f51903a4befee0e7225185bd5fd373089a04653c5
|
|
| MD5 |
549f1b92aa509f69323c8b12852e4832
|
|
| BLAKE2b-256 |
80525290491418935803681dec80d5b530a89393569bc04d70b067855ee66a92
|