This is a package containing three tools for puzzle solving:
- Puzzle Pieces Generator
- Python based (Support command lines and batch generations).
- Web based (Use it without installation) link
- Visualization tool (Web-based Debugger, use it without installation) link
For automatic puzzle solving (fragmented image reassembly) algorithms, please see our project webpage for more information.
A tool for generating puzzles. OpenCV-python is required.
Run python3 generate_puzzle.py -i data/sample.png
.
option | value | description |
---|---|---|
-h --help | show this help message and exit | |
-i | IMG_PATH | Path to the input image. |
-n | PIECE_N | Number of puzzle pieces. Default is 10. The actual number of puzzle pieces may be different. |
-t | SAMPLE_N | Number of puzzle you want to generate from the input image. Default is 1. |
--offset-h | OFFSET_H | Provide the horizontal offset rate when chopping the image. Default is 1. The offset is the rate of the initial rigid piece height. If the value is less than 0.5, no interaction will happen. |
--offset-w | OFFSET_W | Provide the vertical offset rate when chopping the image. Default is 1. The offset is the rate of the initial piece width. If the value is less than 0.5, no interaction will happen. |
-s | SMALL_REGION | A threshold controls the minimum area of a region with respect to initial rigid piece area. Default is 0.25. |
-r | ROTATE | A range of random rotation (in degree) applied on puzzle pieces. Default is 180. The value should be in [0, 180]. Each piece randomly select a rotation degree in [-r, r] |
--bg_color | BG_COLOR | Background color to fill the empty area. Default is [0, 0, 0]. The type is three uint8 numbers in BGR OpenCV format. |
.
├── data
│ ├── puzzles
│ │ ├── 0
│ │ │ ├── config.txt
│ │ │ ├── groundtruth.json
│ │ │ ├── groundtruth.txt
│ │ │ ├── puzzle-0.zip
│ │ │ ├── piece-0.png
│ │ │ ├── piece-1.png
│ │ │ └── ....
│ │ ├── 1
│ │ │ ├── config.txt
│ │ │ ├── groundtruth.json
│ │ │ ├── groundtruth.txt
│ │ │ ├── puzzle-1.zip
│ │ │ ├── piece-0.png
│ │ │ ├── piece-1.png
│ │ │ └── ....
│ │ └── ....
- config.txt:
- First line: prefix of piece images, is always "piece-".
- Second line: number of piece images, one integer.
- Third line: bg color for empty areas in BGR OpenCV format.
- groundtruth.json (used for Debugger in Javascript):
- id: piece id.
- dx: horizontal translation of the piece.
- dy: vertical translation of the piece.
- rotation: clockwise rotation of the piece with respect to the center (radius).
- groundtruth.txt (used for other programs): It is the same as the groundtruth.json, the three values per line are: dx, dy, and rotation.
- puzzle-X.zip (used for Debugger in Javascript): A package contains all piece images and the config file.
This is an earlier version. The pieces' shapes may be irregular. If you need semi-regular puzzle pieces, please refer to the python-based generator above.
- Open the web-based generator website.
- Choose an image file then click
Upload Img
. - Click
Start Chopping
then you can see how the image is cut into pieces. - Click
Save Pieces
to save the puzzle pieces.
A screenshot of the web-based generator:
The visualization tool website.
- Upload pieces in the zip format. The pieces can be generated by the Python-based Generator or the web-based generator.
- Upload a groundtruth file in json format to see the groundtruth composition.
- You can interactively manipulate any two pieces and save the results.
- Click
Select
in thePairwise Interaction
section. - Left click the piece and drag the piece by mouse.
- You can rotate the piece by click either
Left
orRight
.
A screenshot of the visualization tool:
Two sample codes show how to read the generated puzzle into memory and apply the groundtruth on each piece. They are both required OpenCV.
python ./read_puzzle.py
make
./read_puzzle
If you use our codes or tools in your work. Please cite our paper,
JigsawNet: Shredded Image Reassembly Using Convolutional Neural Network and Loop-based Composition.
C. Le and X. Li
IEEE Transactions on Image Processing (TIP), 28(8):4000-4015, 2019.
If you use this tool to generate puzzle datasets, please also cite this github page,
@misc{FragmentRepositoryLSUGVC2018,
title = {Image Puzzle Simulator},
author = {Yongqing Liang and Xin Li},
howpublished = {https://github.com/xmlyqing00/PuzzleSolving-tool},
year = {2018},
}