EmbarkStudios / texture-synthesis

🎨 Example-based texture synthesis written in Rust 🦀
http://embark.rs
Apache License 2.0
1.77k stars 84 forks source link

Add sample mask example #86

Closed Jake-Shadle closed 4 years ago

Jake-Shadle commented 4 years ago

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.

Jake-Shadle commented 4 years ago

Also need to add a test specifically for sample masks as they don't really have an explicit one at the moment. https://github.com/EmbarkStudios/texture-synthesis/issues/85#issuecomment-569887031

Hugo-Trentesaux commented 4 years ago

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")
}
Jake-Shadle commented 4 years ago

Fixed by #98

Jake-Shadle commented 4 years ago

Oops.

Hugo-Trentesaux commented 4 years ago

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

Jake-Shadle commented 4 years ago

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

Hugo-Trentesaux commented 4 years ago

https://github.com/EmbarkStudios/texture-synthesis/pull/112

done ;)