Expand description

texture-synthesis is a light API for Multiresolution Stochastic Texture Synthesis, a non-parametric example-based algorithm for image generation.

First, you build a Session via a SessionBuilder, which follows the builder pattern. Calling build on the SessionBuilder loads all of the input images and checks for various errors.

Session has a run() method that takes all of the parameters and inputs added in the session builder to generated an image, which is returned as a GeneratedImage.

You can save, stream, or inspect the image from GeneratedImage.

Features

  1. Single example generation
  2. Multi example generation
  3. Guided synthesis
  4. Style transfer
  5. Inpainting
  6. Tiling textures

Please, refer to the examples folder in the repository for the features usage examples.

Usage

Session follows a “builder pattern” for defining parameters, meaning you chain functions together.

// Create a new session with default parameters
let session = texture_synthesis::Session::builder()
    // Set some parameters
    .seed(10)
    .nearest_neighbors(20)
    // Specify example images
    .add_example(&"imgs/1.jpg")
    // Build the session
    .build().expect("failed to build session");

// Generate a new image
let generated_img = session.run(None);

// Save the generated image to disk
generated_img.save("my_generated_img.jpg").expect("failed to save generated image");

Re-exports

pub use image;
pub use session::Session;
pub use session::SessionBuilder;

Modules

Structs

A buffer of transforms that were used to generate an image from a set of examples, which can be applied to a different set of input images to get a different output image.

Simple dimensions struct

An example to be used in texture generation

A builder for an Example

An image generated by a Session::run()

Enums

Helper type used to mask ImageSource’s channels

Method used for sampling an example image.

Helper type used to define the source of ImageSource’s data

Functions

Type Definitions