Hi, I’m trying to map an image from cartesian coordinates to polar coordinates (i.e. have the center pixel along the left edge and the outside pixels along the right edge with some pixels warped from outside the image).
I think I can do this with ImageTransformations.jl’s warp & CoordinateTransformations.jl’s PolarFromCartesian() but I’m having trouble getting it working. My code is as follows:
using Images, FileIO, CoordinateTransformations, ImageTransformations
background_color = ones(UInt8, 3) * 255
img = rawview(channelview(load("img/lakspe184.png")))
energy = (background_color .- img) .^ 2
# energy_pol = warp(energy, PolarFromCartesian(), fill=maximum(energy))
energy_pol = warp(energy, PolarFromCartesian())
Which is giving me the following error:
ERROR: LoadError: MethodError: no method matching (::CartesianFromPolar)(::StaticArrays.SArray{Tuple{3},Int64,1,3})
Closest candidates are:
Any(!Matched::Polar) at /home/hans/.julia/packages/CoordinateTransformations/1fp7i/src/coordinatesystems.jl:42
Stacktrace:
[1] autorange(::CartesianIndices{3,Tuple{Base.OneTo{Int64},Base.OneTo{Int64},Base.OneTo{Int64}}}, ::CartesianFromPolar) at /home/hans/.julia/packages/ImageTransformations/jDWnD/src/autorange.jl:7
[2] autorange(::Interpolations.FilledExtrapolation{Int64,3,Interpolations.BSplineInterpolation{Int64,3,Array{Int64,3},Interpolations.BSpline{Interpolations.Linear},Tuple{Base.OneTo{Int64},Base.OneTo{Int64},Base.OneTo{Int64}}},Interpolations.BSpline{Interpolations.Linear},Int64}, ::CartesianFromPolar) at /home/hans/.julia/packages/ImageTransformations/jDWnD/src/autorange.jl:3
[3] warp(::Interpolations.FilledExtrapolation{Int64,3,Interpolations.BSplineInterpolation{Int64,3,Array{Int64,3},Interpolations.BSpline{Interpolations.Linear},Tuple{Base.OneTo{Int64},Base.OneTo{Int64},Base.OneTo{Int64}}},Interpolations.BSpline{Interpolations.Linear},Int64}, ::PolarFromCartesian) at /home/hans/.julia/packages/ImageTransformations/jDWnD/src/warp.jl:83
[4] warp(::Array{Int64,3}, ::PolarFromCartesian) at /home/hans/.julia/packages/ImageTransformations/jDWnD/src/warp.jl:101
[5] image_energy(::MappedArrays.MappedArray{UInt8,3,Base.ReinterpretArray{Normed{UInt8,8},3,RGB{Normed{UInt8,8}},Array{RGB{Normed{UInt8,8}},3}},typeof(reinterpret),ImageCore.var"##37#38"{Normed{UInt8,8}}}) at /home/hans/Documents/content-aware-center-crop/cacc.jl:10
[6] top-level scope at /home/hans/Documents/content-aware-center-crop/cacc.jl:15
[7] include at ./boot.jl:328 [inlined]
[8] include_relative(::Module, ::String) at ./loading.jl:1105
[9] include(::Module, ::String) at ./Base.jl:31
[10] exec_options(::Base.JLOptions) at ./client.jl:295
[11] _start() at ./client.jl:468
in expression starting at /home/hans/Documents/content-aware-center-crop/cacc.jl:15
Can anyone explain what I’m doing wrong?
PS. The commented out line gives an error about warp() not accepting keyword args while the type signature from the docstring looks like this warp(img, tform, [indices], [degree = Linear()], [fill = NaN]) -> imgw
. How can I supply the fill argument correctly?