Crate texture_synthesis

Source
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 session::Session;
pub use session::SessionBuilder;
pub use image;

Modules§

session

Structs§

CoordinateTransform
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.
Dims
Simple dimensions struct
Example
An example to be used in texture generation
ExampleBuilder
A builder for an Example
GeneratedImage
An image generated by a Session::run()

Enums§

ChannelMask
Helper type used to mask ImageSource’s channels
Error
GenericSampleMethod
Method used for sampling an example image.
ImageSource
Helper type used to define the source of ImageSource’s data

Functions§

load_dynamic_image

Type Aliases§

SampleMethod
SamplingMethod