Skip to content
Snippets Groups Projects
Commit c63a8eb3 authored by Stephan Hilb's avatar Stephan Hilb
Browse files

extend image mesh interpolation experiment

parent 1172ce8e
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ import ColorTypes
import CSV
import DataFrames: DataFrame
import FileIO
using ImageQualityIndexes: assess_psnr, assess_ssim
using OpticalFlowUtils
using WriteVTK: paraview_collection
using Plots
......@@ -982,8 +983,11 @@ end
function experiment_image_mesh_interpolation(ctx)
imgf = loadimg(joinpath(ctx.indir, "input.png"))
# TODO: test other meshes
mesh = init_grid(imgf)
df_psnr = DataFrame()
df_ssim = DataFrame()
for mesh_size in (32, 16, 13)
mesh = init_grid(imgf, mesh_size)
space = FeSpace(mesh, P1(), (1,))
u = FeFunction(space)
......@@ -994,12 +998,30 @@ function experiment_image_mesh_interpolation(ctx)
#"clement" => projec_clement!,
"qi_lagrange" => project_qi_lagrange!,
#"qi_lagrange_avg" => project_qi_lagrange!,
#"l2_pixel" => project_l2_pixel!,
"l2_pixel" => project_l2_pixel!,
]
map(methods) do (name, f)
u = FeFunction(space)
f(u, imgf)
save_csv(joinpath(ctx.outdir, name * ".csv"), u)
qualities = map(methods) do (method, f!)
u.data .= false
f!(u, imgf)
save_csv(joinpath(ctx.outdir, "$(mesh_size)_$(method).csv"), u)
imgu = sample(u)
saveimg(joinpath(ctx.outdir, "$(mesh_size)_$(method).png"), imgu)
return method => (
psnr = assess_psnr(imgu, imgf),
ssim = assess_ssim(imgu, imgf))
end
psnr = map(x -> Symbol(first(x)) => last(x).psnr, qualities)
ssim = map(x -> Symbol(first(x)) => last(x).ssim, qualities)
push!(df_psnr, (;mesh_size, psnr...))
push!(df_ssim, (;mesh_size, ssim...))
end
CSV.write(joinpath(ctx.outdir, "psnr.csv"), df_psnr)
CSV.write(joinpath(ctx.outdir, "ssim.csv"), df_ssim)
#savedata(joinpath(ctx.outdir, "data.tex"); energy_min, algparams...)
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment