Skip to main content

Puzzle reconstruction experiments and CLI tooling.

Project description

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:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

puzzletree-0.2.0.tar.gz (27.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

puzzletree-0.2.0-py3-none-any.whl (39.2 kB view details)

Uploaded Python 3

File details

Details for the file puzzletree-0.2.0.tar.gz.

File metadata

  • Download URL: puzzletree-0.2.0.tar.gz
  • Upload date:
  • Size: 27.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.10

File hashes

Hashes for puzzletree-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9595cd0172aea43a04aaedae97420953044bbe41598d9173a35f1fbf5b57fc17
MD5 380591d4847adfdd2555d4ab7a1e2c34
BLAKE2b-256 2ee6502614e9ce67ca015e12c9bee66c0283749667d03506541cd33b633ce522

See more details on using hashes here.

File details

Details for the file puzzletree-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: puzzletree-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 39.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.10

File hashes

Hashes for puzzletree-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 69a0ba670a4a029a764e19d9142063603344cc2abb1815f9472035fa340c10f6
MD5 9a98d256db5de1c5ce8073cea7006c20
BLAKE2b-256 4b15b6685fe914232652a37785081c713beb375c140d7c5b992a3c11fc10129b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page