Skip to main content

Puzzletree

documentation pypi version ci coverage

Puzzle reconstruction experiments.

This project grew out of a puzzle-reconstruction challenge I answered on Mathematica Stack Exchange. The core idea is to use spanning trees as a natural way to assemble puzzles from local matches between neighboring pieces.

In practice, the tree view is also a useful simplification step. You can match the obvious edges first, set a similarity threshold, and reduce a large matching problem into a small number of candidate trees. That leaves the harder ambiguous pieces for a second pass with more specialized algorithms.

Animation output from the city demo:

Tree build animation

Installation

pip install puzzletree

With uv:

uv tool install puzzletree

Reconstruct Demo

The reconstruct command expects a directory of equally sized tile images. The images in tests/test_data are full reference images, so the quickest demo flow is:

  1. Split one of the bundled images into tiles.
  2. Run puzzletree reconstruct on that tile directory.

This example uses tests/test_data/city.jpg and writes tiles into the current directory:

uv run python -m puzzletree tile \
  --input-image tests/test_data/city.jpg

This uses the default 4x5 grid and writes PNG tiles to ./puzzletree-city-tiles.

Then run the CLI from a source checkout:

uv run python -m puzzletree reconstruct \
  --input-dir ./puzzletree-city-tiles \
  --animation ./puzzletree-city-tree-build.gif

This writes the reconstructed image to ./puzzletree-city-reconstructed.png and, when --animation is set, saves animation frames to ./puzzletree-city-frames.

If you installed the package globally, the same command works without uv run:

puzzletree tile --input-image tests/test_data/city.jpg
puzzletree reconstruct --input-dir ./puzzletree-city-tiles

Other bundled demo images:

Metadata

Release files for puzzletree 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for puzzletree 0.2.0
File Size Uploaded Provenance Actions
puzzletree-0.2.0.tar.gz 27.0 kB Without provenance Details for puzzletree-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for puzzletree 0.2.0
File Interpreter ABI Platform Actions
puzzletree-0.2.0-py3-none-any.whl Python 3 none any Details for puzzletree-0.2.0-py3-none-any.whl

Total release size: 66.2 kB

Release files / puzzletree-0.2.0.tar.gz

Download URL puzzletree-0.2.0.tar.gz
Size 27.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9595cd0172aea43a04aaedae97420953044bbe41598d9173a35f1fbf5b57fc17
BLAKE2b-256 checksum
How to use checksums
2ee6502614e9ce67ca015e12c9bee66c0283749667d03506541cd33b633ce522
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.10

Release files / puzzletree-0.2.0-py3-none-any.whl

Download URL puzzletree-0.2.0-py3-none-any.whl
Size 39.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
69a0ba670a4a029a764e19d9142063603344cc2abb1815f9472035fa340c10f6
BLAKE2b-256 checksum
How to use checksums
4b15b6685fe914232652a37785081c713beb375c140d7c5b992a3c11fc10129b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.10

Security for puzzletree 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page