# TransformImages warp error

**URL:** <https://discourse.julialang.org/t/transformimages-warp-error/135663>\
**Category:** General Usage\
**Tags:** question\
**Created:** [February 15, 2026, 8:50pm UTC](https://discourse.julialang.org/t/transformimages-warp-error/135663 "2026-02-15T20:50:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mekapses](https://avatars.discourse-cdn.com/v4/letter/m/b5a626/32.png) [@mekapses](https://discourse.julialang.org/u/mekapses)\
**Post date:** [February 15, 2026, 8:50pm UTC](https://discourse.julialang.org/t/transformimages-warp-error/135663/1 "2026-02-15T20:50:51Z")

</div>

Trying to implement a log polar transform… warp gets a  
MethodError: no method matching similar(::Type{Array{ColorTypes.Gray{Float64}}}, ::Tuple{StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}, StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}})

The function is  
function LogPolar(x)  
# x is an SVector (StaticArrays), e.g., SVector(x\_coord, y\_coord)  
ρ = log(hypot(x[1], x[2])) # hypot(x, y) calculates sqrt(x^2 + y^2)  
θ = atan(x[2], x[1])  
return SVector(ρ, θ)  
end

Not sure what I’m doing wrong

---

<div class="post-metadata">

**Author:** ![technocrat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/technocrat/32/220947_2.png) [@technocrat](https://discourse.julialang.org/u/technocrat)\
**Post date:** [February 15, 2026, 10:46pm UTC](https://discourse.julialang.org/t/transformimages-warp-error/135663/2 "2026-02-15T22:46:23Z")

</div>

It’s hard to tell without a minimal working example, but guessing, you might try something like this:

````julia-auto
using TestImages
using ImageTransformations
using StaticArrays

# Example image
img = Float64.(testimage("cameraman"))
h, w = size(img)

# Choose center and radial scale
cx = (w + 1) / 2
cy = (h + 1) / 2
rmax = min(cx - 1, w - cx, cy - 1, h - cy) # largest radius fully inside image
ρmax = log(rmax + 1) # +1 avoids log(0)

"""
Map output pixel coords (row, col) -> input coords (row, col)
for a log-polar view:
- output row controls log-radius
- output col controls angle
"""
function logpolar(p::SVector{2,<:Real})
    y_out, x_out = p

    # Normalize output coordinates to [0,1]
    u = (y_out - 1) / (h - 1) # radial axis
    v = (x_out - 1) / (w - 1) # angular axis

    # Convert to polar params
    ρ = u * ρmax
    r = exp(ρ) - 1
    θ = 2π * v

    # Back to Cartesian input coordinates
    x_in = cx + r * cos(θ)
    y_in = cy + r * sin(θ)

    return SVector(y_in, x_in)
end

# Warp: output axes same size as input
img_logpolar = warp(img, logpolar, (axes(img, 1), axes(img, 2)))```
````
