From 85ccc5b177659eb321eee80fe8da61485997247a Mon Sep 17 00:00:00 2001 From: Stephan Hilb <stephan@ecshi.net> Date: Fri, 6 May 2022 15:17:37 +0200 Subject: [PATCH] add warping comparison benchmark --- scripts/run.jl | 7 +++++++ scripts/run_experiments.jl | 30 +++++++++++++++++++++++------- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/scripts/run.jl b/scripts/run.jl index 97bb178..3d17003 100644 --- a/scripts/run.jl +++ b/scripts/run.jl @@ -29,3 +29,10 @@ ctx(experiment_inpaint, "fem/inpaint") ctx(experiment_optflow_middlebury_all, "fem/optflow/middlebury") # additional experiments for paper + +# combined inpainting + denoising with mixed noise +ctx(experiment_inpaint_denoise, "fem/optflow/inpaint_denoise") + +# comparison: warping and adaptivity +ctx(experiment_optflow_middlebury_warping_comparison, "fem/optflow/middlebury_warping_comparison") + diff --git a/scripts/run_experiments.jl b/scripts/run_experiments.jl index 27ee90f..3c4c3e0 100644 --- a/scripts/run_experiments.jl +++ b/scripts/run_experiments.jl @@ -1463,13 +1463,12 @@ function optflow(ctx) project_image! = project_l2_lagrange! eps_newton = 1e-3 # cauchy criterion for inner newton loop eps_warp = 0.05 - n_refine = 6 # convert to cartesian coordinates imgf0 = from_img(ctx.params.imgf0) imgf1 = from_img(ctx.params.imgf1) - mesh = init_grid(imgf0, floor.(Int, size(imgf0) ./ 2^(n_refine / 2))...) + mesh = init_grid(imgf0, floor.(Int, size(imgf0) ./ 2^(ctx.params.n_refine / 2))...) mesh_area = area(mesh) # optflow specific stuff @@ -1537,7 +1536,8 @@ function optflow(ctx) println("norm_step = $norm_step_") # interior newton stop criterion - norm_step_ > eps_newton && k_newton < 10 && continue + norm_step_ > eps_newton && k_newton < 30 && continue + ctx.params.warp || break k_newton = 0 @@ -1557,10 +1557,11 @@ function optflow(ctx) # warping stop criterion rel_datachange < -eps_warp && continue + ctx.params.refine || break # refinement stop criterion k_refine += 1 - k_refine > n_refine && break + k_refine > ctx.params.n_refine && break println("refine ...") estimate_res!(st) marked_cells = mark(st; theta = 0.5) @@ -1584,7 +1585,7 @@ function optflow(ctx) imgfw = warp_backwards(imgf1, u_sampled) saveimg(joinpath(ctx.outdir, "fw.png"), to_img(imgfw)) savedata(joinpath(ctx.outdir, "data.tex"); - eps_newton, eps_warp, n_refine, + eps_newton, eps_warp, ctx.params.n_refine, st.alpha1, st.alpha2, st.lambda, st.beta, st.gamma1, st.gamma2, width=size(u_sampled, 1), height=size(u_sampled, 2)) return st @@ -1601,16 +1602,31 @@ function experiment_optflow_middlebury(ctx) return optflow(ctx) end -function experiment_optflow_middlebury_all(ctx) +function experiment_optflow_middlebury_all_benchmarks(ctx) for example in ["Dimetrodon", "Grove2", "Grove3", "Hydrangea", "RubberWhale", "Urban2", "Urban3", "Venus"] ctx(experiment_optflow_middlebury, example; alpha1 = 10., alpha2 = 0., lambda = 1., beta = 1e-5, gamma1 = 1e-4, gamma2 = 1e-4) - return + #return end end +# FIXME: legacy +function experiment_optflow_middlebury_all(ctx) + experiment_optflow_middlebury_all_benchmarks( + Util.Context(ctx; warp = true, refine = true, n_refine = 6)) +end + +function experiment_optflow_middlebury_warping_comparison(ctx) + ctx(experiment_optflow_middlebury_all_benchmarks, "vanilla"; + warp = false, refine = false, n_refine = 0) + ctx(experiment_optflow_middlebury_all_benchmarks, "warping"; + warp = true, refine = false, n_refine = 0) + ctx(experiment_optflow_middlebury_all_benchmarks, "adaptive-warping"; + warp = true, refine = true, n_refine = 6) +end + function test_image(n = 2^6; supersample_factor = 16) q = supersample_factor -- GitLab