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
- Single example generation
- Multi example generation
- Guided synthesis
- Style transfer
- Inpainting
- 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§
Structs§
- Coordinate
Transform - 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
- Example
Builder - A builder for an
Example
- Generated
Image - An image generated by a
Session::run()
Enums§
- Channel
Mask - Helper type used to mask
ImageSource
’s channels - Error
- Generic
Sample Method - Method used for sampling an example image.
- Image
Source - Helper type used to define the source of
ImageSource
’s data