Hi @tim.holy, thanks for the response!
I can’t even reproduce the exact error I was getting from my program anymore . However, my first thought was that it was because integer coordinate transformations were required, and adding x_shift, y_shift = round(x_shift), round(y_shift)
, translations began to work.
Of course, I didn’t just take this as truth and did some testing in the REPL. Turns out that my toy tests were bad because my “images” were integer arrays, and that only seems to work with certain translations. For example
julia> a = [1 2 3; 4 5 6];
julia> t = Translation(.75, .75);
julia> b = warp(a, t, indices_spatial(a), 0); # works
julia> t = Translation(.9, .9);
julia> b = warp(a, t, indices_spatial(a), 0); # doesn't work
ERROR: InexactError: Int64(4.6000000000000005)
Stacktrace:
[1] Type at ./float.jl:703 [inlined]
[2] convert at ./number.jl:7 [inlined]
[3] setindex! at ./array.jl:768 [inlined]
[4] setindex! at ./multidimensional.jl:488 [inlined]
[5] warp!(::Array{Int64,2}, ::Interpolations.FilledExtrapolation{Int64,2,Interpolations.BSplineInterpolation{Int64,2,Array{Int64,2},BSpline{Linear},Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}},BSpline{Linear},Int64}, ::Translation{StaticArrays.SArray{Tuple{2},Float64,1,2}}) at /Users/John/.juliapro/JuliaPro_v1.2.0-1/packages/ImageTransformations/7wC0C/src/warp.jl:89
[6] warp at /Users/John/.juliapro/JuliaPro_v1.2.0-1/packages/ImageTransformations/7wC0C/src/warp.jl:84 [inlined]
[7] warp(::Array{Int64,2}, ::Translation{StaticArrays.SArray{Tuple{2},Float64,1,2}}, ::Tuple{Base.OneTo{Int64},Base.OneTo{Int64}}, ::Int64) at /Users/John/.juliapro/JuliaPro_v1.2.0-1/packages/ImageTransformations/7wC0C/src/warp.jl:96
[8] top-level scope at none:0
julia> b = warp(float.(a), t, indices_spatial(a), 0); # now works!
So, my testing in the REPL falsely led me to believe that integer shifts were required. I wish I could reproduce the error I was having in my program, however, because the image was already float
values.
I do have another question tho. I am looking at the docs and it says there are descriptions of the boundary condition methods under /doc/latex, but I cannot find that in the repo, and I can’t understand the different interpolation methods such as Quadratic(Flat(OnCell()))
.
The behavior I am looking for is:
a = [1 2; 3 4]
t = Translation(.5, .5)
^ just noticed that this also does not work without float casting, and this was probably the example that I first tried and saw InexactError (2.5)
b = warp(a, t, indices_spatial(a), 0)
[2.5 1.5; 1.75 1]
However, the edge pixels become zeros. Is there a method to produce the behavior above?