JuliaMath / JuliaMath/Interpolations.jl
Image warping
- Dominant language
- Julia
- Stars
- 575
- Forks
- 117
- PR merge metrics
- No merged PRs in 30d
Description
I tried to use `Interpolations.jl` to deform an image. I did not see a simple interface for this task, so here is my code:
```julia
using Interpolations, TestImages, BenchmarkTools
img1 = Float32.(testimage("resolution"));
intlin = extrapolate(interpolate(img1, BSpline(Linear())), 0)
mymid = size(img1).÷2 .+1
f(t) = (0.1*t[1]+0.1*t[2], 0.0) # defines the warp as a local shift
@time coords = [Float32.(Tuple(c) .+ f(Tuple(c).-mymid)) for c in CartesianIndices(img1)]
do_int(t) = intlin(t...)
res = zeros(size(img1))
@btime $res .= do_int.($coords);
```
I expected this linear interpolation to be fairly fast, but it takes about 0.8 second for this 1920 x 1920 image and consumes 168 Mb. Is there a way to avoid the allocations?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.