Struct texture_synthesis::session::SessionBuilder [−][src]
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
impl<'a> SessionBuilder<'a>
[src]
pub fn new() -> Self
[src]
Creates a new SessionBuilder
, can also be created via
Session::builder()
pub fn add_example<E: Into<Example<'a>>>(self, example: E) -> Self
[src]
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");
pub fn add_examples<E: Into<Example<'a>>, I: IntoIterator<Item = E>>(
self,
examples: I
) -> Self
[src]
self,
examples: I
) -> Self
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");
pub fn inpaint_example<I: Into<ImageSource<'a>>, E: Into<Example<'a>>>(
self,
inpaint_mask: I,
example: E,
size: Dims
) -> Self
[src]
self,
inpaint_mask: I,
example: E,
size: Dims
) -> Self
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
.
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");
pub fn inpaint_example_channel<E: Into<Example<'a>>>(
self,
mask: ChannelMask,
example: E,
size: Dims
) -> Self
[src]
self,
mask: ChannelMask,
example: E,
size: Dims
) -> Self
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");
pub fn load_target_guide<I: Into<ImageSource<'a>>>(self, guide: I) -> Self
[src]
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
,
pub fn resize_input(self, dims: Dims) -> Self
[src]
Overwrite incoming images sizes
pub fn seed(self, value: u64) -> Self
[src]
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.
pub fn tiling_mode(self, is_tiling: bool) -> Self
[src]
Makes the generator output tiling image.
Default: false.
pub fn nearest_neighbors(self, count: u32) -> Self
[src]
How many neighboring pixels each pixel is aware of during generation.
A larger number means more global structures are captured.
Default: 50
pub fn random_sample_locations(self, count: u64) -> Self
[src]
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
pub fn random_init(self, count: u64) -> Self
[src]
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.
pub fn cauchy_dispersion(self, value: f32) -> Self
[src]
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
pub fn guide_alpha(self, value: f32) -> Self
[src]
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
pub fn backtrack_percent(self, value: f32) -> Self
[src]
The percentage of pixels to be backtracked during each p_stage
.
Range (0,1).
Default: 0.5
pub fn backtrack_stages(self, stages: u32) -> Self
[src]
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
pub fn output_size(self, dims: Dims) -> Self
[src]
Specify size of the generated image.
Default: 500x500
pub fn max_thread_count(self, count: usize) -> Self
[src]
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.
pub fn build(self) -> Result<Session, Error>
[src]
Creates a Session
, or returns an error if invalid parameters or input
images were specified.
Trait Implementations
impl<'a> Default for SessionBuilder<'a>
[src]
fn default() -> SessionBuilder<'a>
[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for SessionBuilder<'a>
impl<'a> Send for SessionBuilder<'a>
impl<'a> Sync for SessionBuilder<'a>
impl<'a> Unpin for SessionBuilder<'a>
impl<'a> UnwindSafe for SessionBuilder<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,