pub struct SessionBuilder<'a> { /* private fields */ }
Expand description

Builds a session by setting parameters and adding input images, calling build will check all of the provided inputs to verify that texture synthesis will provide valid output

Implementations

Creates a new SessionBuilder, can also be created via Session::builder()

Adds an Example from which a generator will synthesize a new image.

See examples/01_single_example_synthesis

Examples
let tex_synth = texture_synthesis::Session::builder()
    .add_example(&"imgs/1.jpg")
    .build().expect("failed to build session");

Adds Examples from which a generator will synthesize a new image.

See examples/02_multi_example_synthesis

Examples
let tex_synth = texture_synthesis::Session::builder()
    .add_examples(&[&"imgs/1.jpg", &"imgs/2.jpg"])
    .build().expect("failed to build session");

Inpaints an example. Due to how inpainting works, a size must also be provided, as all examples, as well as the inpaint mask, must be the same size as each other, as well as the final output image. Using resize_input or output_size is ignored if this method is called.

To prevent sampling from the example, you can specify SamplingMethod::Ignore with Example::set_sample_method.

See examples/05_inpaint

Examples
let tex_synth = texture_synthesis::Session::builder()
    .add_examples(&[&"imgs/1.jpg", &"imgs/3.jpg"])
    .inpaint_example(
        &"masks/inpaint.jpg",
        // This will prevent sampling from the imgs/2.jpg, note that
        // we *MUST* provide at least one example to source from!
        texture_synthesis::Example::builder(&"imgs/2.jpg")
            .set_sample_method(texture_synthesis::SampleMethod::Ignore),
        texture_synthesis::Dims::square(400)
    )
    .build().expect("failed to build session");

Inpaints an example, using a specific channel in the example image as the inpaint mask

Examples
let tex_synth = texture_synthesis::Session::builder()
    .inpaint_example_channel(
        // Let's use inpaint the alpha channel
        texture_synthesis::ChannelMask::A,
        &"imgs/bricks.png",
        texture_synthesis::Dims::square(400)
    )
    .build().expect("failed to build session");

Loads a target guide map.

If no Example guide maps are provided, this will produce a style transfer effect, where the Examples are styles and the target guide is content.

See examples/03_guided_synthesis, or examples/04_style_transfer,

Overwrite incoming images sizes

Changes pseudo-deterministic seed.

Global structures will stay same, if the same seed is provided, but smaller details may change due to undeterministic nature of multithreading.

Makes the generator output tiling image.

Default: false.

How many neighboring pixels each pixel is aware of during generation.

A larger number means more global structures are captured.

Default: 50

The number of random locations that will be considered during a pixel resolution apart from its immediate neighbors.

If unsure, keep same as nearest neighbors.

Default: 50

Forces the first n pixels to be randomly resolved, and prevents them from being overwritten.

Can be an enforcing factor of remixing multiple images together.

The distribution dispersion used for picking best candidate (controls the distribution ‘tail flatness’).

Values close to 0.0 will produce ‘harsh’ borders between generated ‘chunks’. Values closer to 1.0 will produce a smoother gradient on those borders.

For futher reading, check out P.Harrison’s “Image Texture Tools”.

Default: 1.0

Controls the trade-off between guide and example maps.

If doing style transfer, set to about 0.8-0.6 to allow for more global structures of the style.

If you’d like the guide maps to be considered through all generation stages, set to 1.0, which will prevent guide maps weight “decay” during the score calculation.

Default: 0.8

The percentage of pixels to be backtracked during each p_stage. Range (0,1).

Default: 0.5

Controls the number of backtracking stages.

Backtracking prevents ‘garbage’ generation. Right now, the depth of the image pyramid for multiresolution synthesis depends on this parameter as well.

Default: 5

Specify size of the generated image.

Default: 500x500

Controls the maximum number of threads that will be spawned at any one time in parallel.

This number is allowed to exceed the number of logical cores on the system, but it should generally be kept at or below that number.

Setting this number to 1 will result in completely deterministic image generation, meaning that redoing generation with the same inputs will always give you the same outputs.

Default: The number of logical cores on this system.

Creates a Session, or returns an error if invalid parameters or input images were specified.

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.