EmbarkStudios / texture-synthesis

🎨 Example-based texture synthesis written in Rust 🦀

Home Page:http://embark.rs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add sample mask example

Jake-Shadle opened this issue · comments

Though #85 is a bug in structopt, we should still have at least one example of using sample masks, so that if users copy it and replace eg, the input image paths, they won't get this confusing error message.

Also need to add a test specifically for sample masks as they don't really have an explicit one at the moment. #85 (comment)

I wrote this but it seems not to work (runs forever)

use texture_synthesis as ts;

// painting into the 1.jpg image, with the shape given by 3_inpaint.jpg, using pattern of 2.jpg
fn main() -> Result<(), ts::Error> {
    let texsynth = ts::Session::builder()
        .inpaint_example(
            &"imgs/masks/3_inpaint.jpg",
            ts::Example::builder(&"imgs/1.jpg").set_sample_method(ts::SampleMethod::Ignore),
            ts::Dims::square(400),
        )
        .add_example(ts::Example::builder(&"imgs/2.jpg").set_sample_method(ts::SampleMethod::All))
        .build()?;

    let generated = texsynth.run(None);
    generated.save("out/09.jpg")
}

Fixed by #98

Oops.

I think such an example could be added in the README.
I proposed a version here : https://github.com/Hugo-Trentesaux/texture-synthesis#cli-2

Looks good, feel free to make a PR. :)