diff --git a/.gitignore b/.gitignore index 7b2734de89499b527ac108a8ed1772f9b9907fe3..586b8ba75b0c25e9e26aacbf137826c787e7661d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ *.pvd data/* output/* +scripts/data/* diff --git a/Manifest.toml b/Manifest.toml index 592cc398843629ebd992a45d76df708363742c94..15269825527c5ee8e00f7668cdf41fb8c5874248 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -1,6 +1,6 @@ # This file is machine-generated - editing it directly is not advised -julia_version = "1.10.4" +julia_version = "1.9.3" manifest_format = "2.0" project_hash = "170a37ab5d68a18e29bd757512b09ed22a40cf6c" @@ -57,7 +57,7 @@ weakdeps = ["Dates", "LinearAlgebra"] [[deps.CompilerSupportLibraries_jll]] deps = ["Artifacts", "Libdl"] uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" -version = "1.1.1+0" +version = "1.0.5+0" [[deps.Crayons]] git-tree-sha1 = "249fe38abf76d48563e2f4556bebd215aa317e15" @@ -198,26 +198,21 @@ version = "1.3.0" [[deps.LibCURL]] deps = ["LibCURL_jll", "MozillaCACerts_jll"] uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" -version = "0.6.4" +version = "0.6.3" [[deps.LibCURL_jll]] deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" -version = "8.4.0+0" +version = "7.84.0+0" [[deps.LibGit2]] -deps = ["Base64", "LibGit2_jll", "NetworkOptions", "Printf", "SHA"] +deps = ["Base64", "NetworkOptions", "Printf", "SHA"] uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" -[[deps.LibGit2_jll]] -deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll"] -uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5" -version = "1.6.4+0" - [[deps.LibSSH2_jll]] deps = ["Artifacts", "Libdl", "MbedTLS_jll"] uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" -version = "1.11.0+1" +version = "1.10.2+0" [[deps.Libdl]] uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" @@ -270,7 +265,7 @@ uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" [[deps.MbedTLS_jll]] deps = ["Artifacts", "Libdl"] uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" -version = "2.28.2+1" +version = "2.28.2+0" [[deps.Missings]] deps = ["DataAPI"] @@ -283,7 +278,7 @@ uuid = "a63ad114-7e13-5084-954f-fe012c677804" [[deps.MozillaCACerts_jll]] uuid = "14a3606d-f60d-562e-9121-12d972cd8159" -version = "2023.1.10" +version = "2022.10.11" [[deps.NaNMath]] deps = ["OpenLibm_jll"] @@ -298,12 +293,12 @@ version = "1.2.0" [[deps.OpenBLAS_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" -version = "0.3.23+4" +version = "0.3.21+4" [[deps.OpenLibm_jll]] deps = ["Artifacts", "Libdl"] uuid = "05823500-19ac-5b8b-9628-191a04bc5112" -version = "0.8.1+2" +version = "0.8.1+0" [[deps.OpenSpecFun_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"] @@ -325,7 +320,7 @@ version = "2.7.2" [[deps.Pkg]] deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" -version = "1.10.0" +version = "1.9.2" [[deps.PooledArrays]] deps = ["DataAPI", "Future"] @@ -360,7 +355,7 @@ deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" [[deps.Random]] -deps = ["SHA"] +deps = ["SHA", "Serialization"] uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" [[deps.Reexport]] @@ -399,7 +394,6 @@ version = "1.1.1" [[deps.SparseArrays]] deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"] uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" -version = "1.10.0" [[deps.SpecialFunctions]] deps = ["IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"] @@ -431,7 +425,7 @@ version = "1.4.2" [[deps.Statistics]] deps = ["LinearAlgebra", "SparseArrays"] uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" -version = "1.10.0" +version = "1.9.0" [[deps.StringManipulation]] deps = ["PrecompileTools"] @@ -440,9 +434,9 @@ uuid = "892a3eda-7b42-436c-8928-eab12a02cf0e" version = "0.3.4" [[deps.SuiteSparse_jll]] -deps = ["Artifacts", "Libdl", "libblastrampoline_jll"] +deps = ["Artifacts", "Libdl", "Pkg", "libblastrampoline_jll"] uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c" -version = "7.2.1+1" +version = "5.10.1+6" [[deps.TOML]] deps = ["Dates"] @@ -514,19 +508,19 @@ version = "2.10.4+0" [[deps.Zlib_jll]] deps = ["Libdl"] uuid = "83775a58-1f1d-513f-b197-d71354ab007a" -version = "1.2.13+1" +version = "1.2.13+0" [[deps.libblastrampoline_jll]] deps = ["Artifacts", "Libdl"] uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" -version = "5.8.0+1" +version = "5.8.0+0" [[deps.nghttp2_jll]] deps = ["Artifacts", "Libdl"] uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" -version = "1.52.0+1" +version = "1.48.0+0" [[deps.p7zip_jll]] deps = ["Artifacts", "Libdl"] uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" -version = "17.4.0+2" +version = "17.4.0+0" diff --git a/scripts/Manifest.toml b/scripts/Manifest.toml index a16d55fb0efe465767ecfe83aa1017ef22a7b7f2..0c3d99bb12861913acb118f55ac231851391382e 100644 --- a/scripts/Manifest.toml +++ b/scripts/Manifest.toml @@ -1,6 +1,6 @@ # This file is machine-generated - editing it directly is not advised -julia_version = "1.10.4" +julia_version = "1.9.3" manifest_format = "2.0" project_hash = "dd7a5d2ab7a492a873a1e158d67133f8310cff18" @@ -197,7 +197,7 @@ weakdeps = ["Dates", "LinearAlgebra"] [[deps.CompilerSupportLibraries_jll]] deps = ["Artifacts", "Libdl"] uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" -version = "1.1.1+0" +version = "1.0.5+0" [[deps.ComputationalResources]] git-tree-sha1 = "52cb3ec90e8a8bea0e62e275ba577ad0f74821f7" @@ -737,26 +737,21 @@ version = "0.3.1" [[deps.LibCURL]] deps = ["LibCURL_jll", "MozillaCACerts_jll"] uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21" -version = "0.6.4" +version = "0.6.3" [[deps.LibCURL_jll]] deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll", "Zlib_jll", "nghttp2_jll"] uuid = "deac9b47-8bc7-5906-a0fe-35ac56dc84c0" -version = "8.4.0+0" +version = "7.84.0+0" [[deps.LibGit2]] -deps = ["Base64", "LibGit2_jll", "NetworkOptions", "Printf", "SHA"] +deps = ["Base64", "NetworkOptions", "Printf", "SHA"] uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" -[[deps.LibGit2_jll]] -deps = ["Artifacts", "LibSSH2_jll", "Libdl", "MbedTLS_jll"] -uuid = "e37daf67-58a4-590a-8e99-b0245dd2ffc5" -version = "1.6.4+0" - [[deps.LibSSH2_jll]] deps = ["Artifacts", "Libdl", "MbedTLS_jll"] uuid = "29816b5a-b9ab-546f-933c-edad1886dfa8" -version = "1.11.0+1" +version = "1.10.2+0" [[deps.Libdl]] uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" @@ -896,7 +891,7 @@ version = "1.1.7" [[deps.MbedTLS_jll]] deps = ["Artifacts", "Libdl"] uuid = "c8ffd9c3-330d-5841-b78e-0817d7145fa1" -version = "2.28.2+1" +version = "2.28.2+0" [[deps.Measures]] git-tree-sha1 = "c13304c81eec1ed3af7fc20e75fb6b26092a1102" @@ -920,7 +915,7 @@ version = "0.3.4" [[deps.MozillaCACerts_jll]] uuid = "14a3606d-f60d-562e-9121-12d972cd8159" -version = "2023.1.10" +version = "2022.10.11" [[deps.NaNMath]] deps = ["OpenLibm_jll"] @@ -953,7 +948,7 @@ version = "1.3.5+1" [[deps.OpenBLAS_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" -version = "0.3.23+4" +version = "0.3.21+4" [[deps.OpenEXR]] deps = ["Colors", "FileIO", "OpenEXR_jll"] @@ -970,7 +965,7 @@ version = "3.1.4+0" [[deps.OpenLibm_jll]] deps = ["Artifacts", "Libdl"] uuid = "05823500-19ac-5b8b-9628-191a04bc5112" -version = "0.8.1+2" +version = "0.8.1+0" [[deps.OpenSSL]] deps = ["BitFlags", "Dates", "MozillaCACerts_jll", "OpenSSL_jll", "Sockets"] @@ -1010,7 +1005,7 @@ version = "1.6.2" [[deps.PCRE2_jll]] deps = ["Artifacts", "Libdl"] uuid = "efcefdf7-47ab-520b-bdef-62a2eaa19f15" -version = "10.42.0+1" +version = "10.42.0+0" [[deps.PGFPlotsX]] deps = ["ArgCheck", "Dates", "DefaultApplication", "DocStringExtensions", "MacroTools", "OrderedCollections", "Parameters", "Requires", "Tables"] @@ -1068,7 +1063,7 @@ version = "0.42.2+0" [[deps.Pkg]] deps = ["Artifacts", "Dates", "Downloads", "FileWatching", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" -version = "1.10.0" +version = "1.9.2" [[deps.PkgVersion]] deps = ["Pkg"] @@ -1171,7 +1166,7 @@ deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"] uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" [[deps.Random]] -deps = ["SHA"] +deps = ["SHA", "Serialization"] uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" [[deps.RangeArrays]] @@ -1317,7 +1312,6 @@ version = "1.1.1" [[deps.SparseArrays]] deps = ["Libdl", "LinearAlgebra", "Random", "Serialization", "SuiteSparse_jll"] uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" -version = "1.10.0" [[deps.SpecialFunctions]] deps = ["IrrationalConstants", "LogExpFunctions", "OpenLibm_jll", "OpenSpecFun_jll"] @@ -1370,7 +1364,7 @@ version = "1.4.2" [[deps.Statistics]] deps = ["LinearAlgebra", "SparseArrays"] uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" -version = "1.10.0" +version = "1.9.0" [[deps.StatsAPI]] deps = ["LinearAlgebra"] @@ -1395,9 +1389,9 @@ deps = ["Libdl", "LinearAlgebra", "Serialization", "SparseArrays"] uuid = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9" [[deps.SuiteSparse_jll]] -deps = ["Artifacts", "Libdl", "libblastrampoline_jll"] +deps = ["Artifacts", "Libdl", "Pkg", "libblastrampoline_jll"] uuid = "bea87d4a-7f5b-5778-9afe-8cc45184846c" -version = "7.2.1+1" +version = "5.10.1+6" [[deps.TOML]] deps = ["Dates"] @@ -1690,7 +1684,7 @@ version = "1.5.0+0" [[deps.Zlib_jll]] deps = ["Libdl"] uuid = "83775a58-1f1d-513f-b197-d71354ab007a" -version = "1.2.13+1" +version = "1.2.13+0" [[deps.Zstd_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl"] @@ -1719,7 +1713,7 @@ version = "0.15.1+0" [[deps.libblastrampoline_jll]] deps = ["Artifacts", "Libdl"] uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" -version = "5.8.0+1" +version = "5.8.0+0" [[deps.libfdk_aac_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] @@ -1748,12 +1742,12 @@ version = "1.3.7+1" [[deps.nghttp2_jll]] deps = ["Artifacts", "Libdl"] uuid = "8e850ede-7688-5339-a07c-302acd2aaf8d" -version = "1.52.0+1" +version = "1.48.0+0" [[deps.p7zip_jll]] deps = ["Artifacts", "Libdl"] uuid = "3f19e933-33d8-53b3-aaab-bd5110c3b7a0" -version = "17.4.0+2" +version = "17.4.0+0" [[deps.x264_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] diff --git a/scripts/run.jl b/scripts/run.jl index 8c432e92c40a6ccfa776d829b113c7b039a0b3ee..1084c1f8a2392ea8bd7dfa14de2e948be0f9a46f 100644 --- a/scripts/run.jl +++ b/scripts/run.jl @@ -1,12 +1,15 @@ include("run_experiments.jl") -const datapath = joinpath(@__DIR__, "../../data") -const outpath = joinpath(@__DIR__, "../../data") +#const datapath = joinpath(@__DIR__, "../../data") +#const outpath = joinpath(@__DIR__, "../../data") +const datapath = joinpath(@__DIR__, "data") +const outpath = joinpath(@__DIR__, "data") ctx = Util.Context(datapath, outpath) # NOTE: make sure middlebury data is available in each of the directories! - +ctx(experiment_optflow_middlebury_warping_comparison, "fem/opticalflow/middlebury_alpha3") +#ctx(experiment_inpaint_adaptive, "fem/inpaint_adaptive") function paper1(ctx) # newton vs other algs ctx(experiment_convergence_rate, "fem/convergence/rate") @@ -19,6 +22,7 @@ function paper1(ctx) end function paper2(ctx) + # comparison: image mesh interpolation methods ctx(experiment_image_mesh_interpolation, "image-mesh-interpolation") # optflow comparison: vanilla / warping / adaptive @@ -26,3 +30,4 @@ function paper2(ctx) # adaptive inpainting ctx(experiment_inpaint_adaptive, "fem/inpaint_adaptive") end + diff --git a/scripts/run_experiments.jl b/scripts/run_experiments.jl index 2bef78c3758240d936fc120cf355c7d6dde6dd62..a194e647aec544ecb1473481ffb9356c0cf25c22 100644 --- a/scripts/run_experiments.jl +++ b/scripts/run_experiments.jl @@ -1335,14 +1335,18 @@ end # NOTE: used also by inpaint_denoise experiment function inpaint(ctx) # expect ctx.params.g_arr - + duration = @elapsed begin #project_image! = project_l2_lagrange! project_image! = project_qi_lagrange! # convert to cartesian coordinates g_arr = from_img(ctx.params.g_arr) mask_arr = from_img(ctx.params.mask_arr) - + #println(typeof(g_arr),size(g_arr),floor.(Int, size(g_arr) ./ 2^(ctx.params.n_refine / 2))) + dim_g=size(g_arr) + dim_refine=floor.(Int, size(g_arr) ./ 2^(ctx.params.n_refine / 2)) + N_refine = floor.(Int, log2((dim_g[1]-1)*(dim_g[2]-1)/((dim_refine[1]-1)*(dim_refine[2]-1)))) + println("Number of refinements: ", N_refine) mesh = init_grid(g_arr, floor.(Int, size(g_arr) ./ 2^(ctx.params.n_refine / 2))...) mesh_area = area(mesh) @@ -1406,7 +1410,8 @@ function inpaint(ctx) # refinement stop criterion k_refine += 1 - k_refine > ctx.params.n_refine && break + # k_refine > ctx.params.n_refine && break + k_refine > N_refine && break println("refine ...") #estimate_res!(st) marked_cells = Set(mark(st; theta = 0.5)) @@ -1436,15 +1441,18 @@ function inpaint(ctx) end end #CSV.write(joinpath(ctx.outdir, "energies.csv"), df) - + end#end @elapsed + u_sampled = sample(st.u) saveimg(joinpath(ctx.outdir, "g.png"), grayclamp.(to_img(g_arr))) saveimg(joinpath(ctx.outdir, "output.png"), grayclamp.(to_img(u_sampled))) + psnr = assess_psnr(u_sampled, g_arr) + ssim = assess_ssim(u_sampled, g_arr) #save_csv(joinpath(ctx.outdir, "mesh.csv"), st.u) savedata(joinpath(ctx.outdir, "data.tex"); ctx.params.eps_newton, 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)) + width=size(u_sampled, 1), height=size(u_sampled, 2), duration,psnr,ssim, N_refine) return st end @@ -1452,25 +1460,29 @@ function experiment_inpaint_adaptive(ctx) g_arr = loadimg(joinpath(ctx.indir, "input.png")) mask_arr = loadimg(joinpath(ctx.indir, "mask.png")) mesh = init_grid(g_arr;) - - params = ( - name = "test", - n_refine = 5, - g_arr, mask_arr, mesh, - #alpha1 = 0.2, alpha2 = 8., lambda = 1., - alpha1 = 0., alpha2 = 50., lambda = 1., - beta = 1e-5, S = Operators.SIdentity(), - gamma1 = 1e-4, gamma2 = 1e-4, - eps_newton = 1e-4) - - savedata(joinpath(ctx.outdir, "data.tex"); - params.eps_newton, params.n_refine, - params.alpha1, params.alpha2, params.lambda, - params.gamma1, params.gamma2, - params.beta, params.S, - width=size(g_arr, 1), height=size(g_arr, 2)) - - ctx(inpaint; params...) + for coarsen in 0:15 + params = ( + name = "test", + n_refine = coarsen, + g_arr, mask_arr, mesh, + #alpha1 = 0.2, alpha2 = 8., lambda = 1., + alpha1 = 0., alpha2 = 50., lambda = 1., + beta = 1e-5, S = Operators.SIdentity(), + gamma1 = 1e-4, gamma2 = 1e-4, + eps_newton = 1e-4) + + savedata(joinpath(ctx.outdir, "data.tex"); + params.eps_newton, params.n_refine, + params.alpha1, params.alpha2, params.lambda, + params.gamma1, params.gamma2, + params.beta, params.S, + width=size(g_arr, 1), height=size(g_arr, 2)) + beta=1e-5 + #ctx(inpaint; params...) + ctx(inpaint, "s-identity_alpha1_$(round(Int,params.alpha1))_alpha2_$(round(Int,params.alpha2))_coarse_$(params.n_refine)"; params..., + S = Operators.SIdentity(), beta = beta) + end + end function experiment_inpaint_denoise(ctx) @@ -1688,7 +1700,7 @@ 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, + alpha1 = 3., alpha2 = 0., lambda = 1., beta = 1e-5, gamma1 = 1e-4, gamma2 = 1e-4, Schoice = :nabla, newton_max_iters = 30) end end @@ -1709,10 +1721,10 @@ 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"; - warp = true, refine = true, n_refine = 6) + #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 experiment_optflow_schoice(ctx)