Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • stephan.hilb/SemiSmoothNewton.jl
1 result
Select Git revision
Show changes
Commits on Source (5)
...@@ -19,20 +19,27 @@ ctx(experiment_convergence_rate, "fem/convergence/rate") ...@@ -19,20 +19,27 @@ ctx(experiment_convergence_rate, "fem/convergence/rate")
# pd est, L1-TV, bad # pd est, L1-TV, bad
# applications # misc experiments
# denoising # inpainting (OLD)
ctx(experiment_denoise, "fem/denoise")
# inpainting
ctx(experiment_inpaint, "fem/inpaint") ctx(experiment_inpaint, "fem/inpaint")
# adaptive optical flow # adaptive optical flow
ctx(experiment_optflow_middlebury_all, "fem/optflow/middlebury") ctx(experiment_optflow_middlebury_all, "fem/optflow/middlebury")
# additional experiments for paper function paper1(ctx)
# newton vs other algs
# combined inpainting + denoising with mixed noise ctx(experiment_convergence_rate, "fem/convergence/rate")
ctx(experiment_inpaint_denoise, "fem/optflow/inpaint_denoise") # denoising
ctx(experiment_denoise, "fem/denoise")
# comparison: warping and adaptivity # combined inpainting + denoising with mixed noise
ctx(experiment_optflow_middlebury_warping_comparison, "fem/optflow/middlebury_warping_comparison") ctx(experiment_inpaint_denoise, "fem/inpaint_denoise")
# comparison: warping and adaptivity
ctx(experiment_optflow_middlebury_warping_comparison, "fem/opticalflow/middlebury_warping_comparison")
end
function paper2(ctx)
# comparison: warping and adaptivity
# TODO: adaptivity parameter?
ctx(experiment_optflow_middlebury_warping_comparison, "fem/opticalflow/middlebury_warping_comparison")
end
...@@ -988,10 +988,12 @@ function denoise_pd(ctx) ...@@ -988,10 +988,12 @@ function denoise_pd(ctx)
# semi-implicit primal dual parameters # semi-implicit primal dual parameters
mu = st.alpha2 + st.beta # T = I, S = I mu = st.alpha2 + st.beta # T = I, S = I
mu /= 100 # kind of arbitrary? #mu /= 100 # kind of arbitrary?
tau = 1e-1
L = norm_gradient(mesh) L = norm_gradient(mesh)
#tau = 1e-1
tau = 1 / L
#L = 100
sigma = inv(tau * L^2) sigma = inv(tau * L^2)
theta = NaN # initialized later theta = NaN # initialized later
...@@ -1022,6 +1024,7 @@ function denoise_pd(ctx) ...@@ -1022,6 +1024,7 @@ function denoise_pd(ctx)
while true while true
k += 1 k += 1
if ctx.params.algorithm == :pd1 if ctx.params.algorithm == :pd1
theta = 1 / sqrt(1 + 2 * mu * tau) # constant
# no step size control # no step size control
step_pd2!(st; sigma, tau, theta) step_pd2!(st; sigma, tau, theta)
elseif ctx.params.algorithm == :pd2 elseif ctx.params.algorithm == :pd2
...@@ -1322,6 +1325,7 @@ function experiment_approximation(ctx) ...@@ -1322,6 +1325,7 @@ function experiment_approximation(ctx)
end end
# TODO: deduplicate, cf. optflow() # TODO: deduplicate, cf. optflow()
# NOTE: used also by inpaint_denoise experiment
function inpaint(ctx) function inpaint(ctx)
# expect ctx.params.g_arr # expect ctx.params.g_arr
...@@ -1350,13 +1354,15 @@ function inpaint(ctx) ...@@ -1350,13 +1354,15 @@ function inpaint(ctx)
if ctx.params.n_refine == 0 if ctx.params.n_refine == 0
# if we use a grid at image resolution, we wan't to avoid # if we use a grid at image resolution, we wan't to avoid
# information loss at all cost. # information loss at all cost.
# projet_l2_pixel is not suited for inpainting as it is a global # project_l2_pixel is not suited for inpainting as it is a global
# operator, which may leak data from the inpainting domain # operator, which may leak data from the inpainting domain
interpolate!(st.g, x -> evaluate_bilinear(g_arr, x)) interpolate!(st.g, x -> evaluate_bilinear(g_arr, x))
interpolate!(st.tdata, x -> evaluate_bilinear(mask_arr, x))
else else
project_image!(st.g, g_arr) project_image!(st.g, g_arr)
# TODO: maybe a more conservative choice would be good
project_image!(st.tdata, mask_arr)
end end
project_image!(st.tdata, mask_arr)
end end
save_step(i) = save_step(i) =
...@@ -1427,7 +1433,7 @@ function inpaint(ctx) ...@@ -1427,7 +1433,7 @@ function inpaint(ctx)
u_sampled = sample(st.u) u_sampled = sample(st.u)
saveimg(joinpath(ctx.outdir, "g.png"), grayclamp.(to_img(g_arr))) saveimg(joinpath(ctx.outdir, "g.png"), grayclamp.(to_img(g_arr)))
saveimg(joinpath(ctx.outdir, "output.png"), grayclamp.(to_img(u_sampled))) saveimg(joinpath(ctx.outdir, "output.png"), grayclamp.(to_img(u_sampled)))
save_csv(joinpath(ctx.outdir, "mesh.csv"), st.u) #save_csv(joinpath(ctx.outdir, "mesh.csv"), st.u)
savedata(joinpath(ctx.outdir, "data.tex"); savedata(joinpath(ctx.outdir, "data.tex");
ctx.params.eps_newton, ctx.params.n_refine, ctx.params.eps_newton, ctx.params.n_refine,
st.alpha1, st.alpha2, st.lambda, st.beta, st.gamma1, st.gamma2, st.alpha1, st.alpha2, st.lambda, st.beta, st.gamma1, st.gamma2,
...@@ -1495,7 +1501,12 @@ function optflow(ctx) ...@@ -1495,7 +1501,12 @@ function optflow(ctx)
size(ctx.params.imgf0) == size(ctx.params.imgf1) || size(ctx.params.imgf0) == size(ctx.params.imgf1) ||
throw(ArgumentError("non-matching image sizes")) throw(ArgumentError("non-matching image sizes"))
project_image! = project_l2_lagrange! #project_image! = project_l2_lagrange!
project_image!(f, img) =
ctx.params.n_refine == 0 ?
interpolate!(f, x -> evaluate_bilinear(img, x)) : # fine mesh
project_l2_lagrange! # coarse adaptive mesh
eps_newton = 1e-3 # cauchy criterion for inner newton loop eps_newton = 1e-3 # cauchy criterion for inner newton loop
eps_warp = 0.05 eps_warp = 0.05
...@@ -1672,6 +1683,13 @@ function experiment_optflow_middlebury_warping_comparison(ctx) ...@@ -1672,6 +1683,13 @@ function experiment_optflow_middlebury_warping_comparison(ctx)
warp = false, refine = false, n_refine = 0) warp = false, refine = false, n_refine = 0)
ctx(experiment_optflow_middlebury_all_benchmarks, "warping"; ctx(experiment_optflow_middlebury_all_benchmarks, "warping";
warp = true, refine = false, n_refine = 0) warp = true, refine = false, n_refine = 0)
end
function experiment_optflow_middlebury_warping_comparison_adaptive(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"; ctx(experiment_optflow_middlebury_all_benchmarks, "adaptive-warping";
warp = true, refine = true, n_refine = 6) warp = true, refine = true, n_refine = 6)
end end
......