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

save image difference for optflow

parent ea9ba79d
Branches
Tags
No related merge requests found
......@@ -32,6 +32,13 @@ loadimg(x) = Float64.(FileIO.load(x))
saveimg(io, x::Array{<:Gray}) = FileIO.save(io, grayclamp.(x))
saveimg(io, x) = FileIO.save(io, x)
function saveimgdiff(io, f0, f1)
n = 2^8 # colors
cmap = colormap("RdBu", n)
k(v0, v1) = cmap[clamp(ceil(Int, n * ((v1 - v0) / 2 + 0.5)), 1, n)]
saveimg(io, k.(f0, f1))
end
# convert image to/from image coordinate system
from_img(arr) = permutedims(reverse(arr; dims = 1))
to_img(arr) = permutedims(reverse(arr; dims = 2))
......@@ -1191,6 +1198,7 @@ function optflow(ctx)
u_sampled = sample(st.u)
saveimg(joinpath(ctx.outdir, "f0.png"), to_img(imgf0))
saveimg(joinpath(ctx.outdir, "f1.png"), to_img(imgf1))
saveimgdiff(joinpath(ctx.outdir, "g.png"), to_img(imgf0), to_img(imgf1))
saveimg(joinpath(ctx.outdir, "output.png"), colorflow(to_img(u_sampled); ctx.params.maxflow))
imgfw = warp_backwards(imgf1, u_sampled)
saveimg(joinpath(ctx.outdir, "fw.png"), to_img(imgfw))
......
......@@ -442,3 +442,15 @@ function project_l2_pixel!(u::FeFunction, img)
u.data .= A \ b
return u
end
function save_csv(path, img::AbstractArray{<:Any,2})
df = DataFrame()
for ci in CartesianIndices(img)
push!(df, (
x = ci[1],
y = ci[2],
f_xy = img[ci],
))
end
CSV.write(path, df)
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment