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

improve on warping

parent 8916fc05
No related branches found
No related tags found
No related merge requests found
...@@ -15,13 +15,14 @@ function interpolate_bilinear(img, x) ...@@ -15,13 +15,14 @@ function interpolate_bilinear(img, x)
end end
function warp_backwards(img, u) function warp_backwards(img, u)
axes(img) == axes(u)[2:end] || d = ndims(img)
axes(img) == axes(u)[2:end] && d == size(u, 1) ||
throw(ArgumentError("invalid dimensions")) throw(ArgumentError("invalid dimensions"))
res = similar(img) res = similar(img)
for I in CartesianIndices(img) for I in CartesianIndices(img)
x = Tuple(I) .+ u[:, I] x = Tuple(I) .+ ntuple(i -> u[i, I], d)
res[I] = interpolate_bilinear(img, (x...,)) res[I] = interpolate_bilinear(img, x)
end end
return res return res
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment