Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
🎨 texture-synthesis
A light API for Multiresolution Stochastic Texture Synthesis [1], a non-parametric example-based algorithm for image generation.
The repo also includes multiple code examples to get you started (along with test images), and you can find a compiled binary with a command line interface under the release tab.
Features and examples
1. Single example generation
Generate similar-looking images from a single example.
Below is how to do it with the texture-synthesis API:
extern crate texture_synthesis;
This code snippet can be found in examples/01_single_example_synthesis.rs
To replicate this example with the command line binary run:
texture_synthesis.exe --examples imgs/1.jpg --save out/01.jpg
2. Multi example generation
We can also provide multiple example images and the algorithm will "remix" them into a new image.
Below is how to do it with the texture-synthesis API:
extern crate texture_synthesis;
This code snippet can be found in examples/02_multi_example_synthesis.rs
To replicate this example with the command line binary run:
texture_synthesis.exe --examples imgs/multiexample/1.jpg,imgs/multiexample/2.jpg,imgs/multiexample/3.jpg,imgs/multiexample/4.jpg --rand-init 10 --in-size 300x300 --save out/02.jpg --debug-maps
3. Guided Synthesis
We can also guide the generation by providing a transformation "FROM"-"TO" in a form of guide maps
Below is how to do it with the texture-synthesis API:
extern crate texture_synthesis;
This code snippet can be found in examples/03_guided_synthesis.rs
To replicate this example with the command line binary run:
texture_synthesis.exe --examples imgs/2.jpg --example-guide imgs/masks/2_example.jpg --target-guide imgs/masks/2_target.jpg --save out/03.jpg
4. Style Transfer
Texture synthesis API supports auto-generation of example guide maps, which would produce a style transfer like effect.
Below is how to do it with the texture-synthesis API:
extern crate texture_synthesis;
This code snippet can be found in examples/04_style_transfer.rs
To replicate this example with the command line binary run:
texture_synthesis.exe --examples imgs/multiexample/4.jpg --target-guide imgs/tom.jpg --alpha 0.8 --save out/04.jpg
5. Inpaint
We can also fill-in missing information with inpaint. By changing the seed, we will get different version of the 'fillment'.
Below is how to do it with the texture-synthesis API:
extern crate texture_synthesis;
This code snippet can be found in examples/05_inpaint.rs
To replicate this example with the command line binary run:
texture_synthesis.exe --examples imgs/3.jpg --inpaint imgs/masks/3_inpaint.jpg --sample-masks imgs/masks/3_inpaint.jpg --in-size 400x400 --out-size 400x400 --save out/05.jpg
6. Tiling texture
We can make the generated image tile (meaning it will not have seams if you put multiple images together side-by-side). By invoking inpaint mode together with tiling, we can make an existing image tile.
Below is how to do it with the texture-synthesis API:
extern crate texture_synthesis;
This code snippet can be found in examples/06_tiling_texture.rs
To replicate this example with the command line binary run:
texture_synthesis.exe --examples imgs/1.jpg --inpaint imgs/masks/1_tile.jpg --sample-masks imgs/masks/1_tile.jpg --in-size 400x400 --out-size 400x400 --tiling --save out/06.jpg
7. Combining texture synthesis 'verbs'
We can also combine multiple modes together. For example, multi-example guided synthesis:
Or chaining multiple stages of generation together:
Command line binary
Instruction on how to use:
- download the binary from the release tab (alternatively, you can compile it yourself. the source is in
src\cmd.rs
) - open the terminal (on windows: search for
cmd
) - navigate to the folder containing the
texture_synthesis.exe
(for ex: cd C:\Downloads\texture-synthesis) - run
texture_synthesis.exe --help
(this will give you a list of all commands you can run) - refer to the examples section in this readme for examples of running the binary
Limitations
- Struggles with complex semantics beyond pixel color (unless you guide it)
- Not great with regular textures (seams can become obvious)
- Cannot infer new information from existing information (only operates on what’s already there)
- Designed for single exemplars or very small datasets (unlike Deep Learning based approaches)
Links/references
[1] [Opara & Stachowiak] "More Like This, Please! Texture Synthesis and Remixing from a Single Example"
[2] [Harrison] Image Texture Tools
[3] [Ashikhmin] Synthesizing Natural Textures
[4] [Efros & Leung] Texture Synthesis by Non-parametric Sampling
[5] [Wey & Levoy] Fast Texture Synthesis using Tree-structured Vector Quantization
[6] [De Bonet] Multiresolution Sampling Procedure for Analysis and Synthesis of Texture Images
[7] All the test images in this repo are from Unsplash
Contributing
We welcome community contributions to this project.
Please read our Contributor Guide for more information on how to get started.
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.