# Fft of Matrix type doesnt work?

**URL:** <https://discourse.julialang.org/t/fft-of-matrix-type-doesnt-work/62902>\
**Category:** New to Julia\
**Tags:** images, fftw\
**Created:** [June 14, 2021, 6:27pm UTC](https://discourse.julialang.org/t/fft-of-matrix-type-doesnt-work/62902 "2021-06-14T18:27:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgalenb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mgalenb/32/5645_2.png) [@mgalenb](https://discourse.julialang.org/u/mgalenb)\
**Post date:** [June 14, 2021, 6:27pm UTC](https://discourse.julialang.org/t/fft-of-matrix-type-doesnt-work/62902/1 "2021-06-14T18:27:02Z")

</div>

I am trying to do a 2D FFT of an image:

```julia
using AbstractFFT
img=[sin(2*pi*x*10/256) for x in 1:256, y in 1:256];
fft(img)

```

but this gives:

```julia
julia> fft(img)
ERROR: MethodError: no method matching plan_fft(::Matrix{ComplexF64}, ::UnitRange{Int64})
Closest candidates are:
  plan_fft(::AbstractArray{var"#s6", N} where {var"#s6"<:Real, N}, ::Any; kws...) at /Users/burke/.julia/packages/AbstractFFTs/JebmH/src/definitions.jl:199
  plan_fft(::AbstractArray{var"#s15", N} where {var"#s15"<:(Complex{var"#s16"} where var"#s16"<:Union{Integer, Rational}), N}, ::Any; kws...) at /Users/burke/.julia/packages/AbstractFFTs/JebmH/src/definitions.jl:201
  plan_fft(::AbstractArray; kws...) at /Users/burke/.julia/packages/AbstractFFTs/JebmH/src/definitions.jl:52
Stacktrace:
 [1] fft(x::Matrix{ComplexF64}, region::UnitRange{Int64})
   @ AbstractFFTs ~/.julia/packages/AbstractFFTs/JebmH/src/definitions.jl:51
 [2] fft(x::Matrix{Float64}, region::UnitRange{Int64}) (repeats 2 times)
   @ AbstractFFTs ~/.julia/packages/AbstractFFTs/JebmH/src/definitions.jl:198
 [3] top-level scope
   @ REPL[27]:1

```

what am i missing?

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [June 14, 2021, 7:14pm UTC](https://discourse.julialang.org/t/fft-of-matrix-type-doesnt-work/62902/2 "2021-06-14T19:14:42Z")

</div>

Why using `AbstractFFT` and not just `FFTW`?  
See this [post](https://discourse.julialang.org/t/i-succeeded-to-2d-fft-of-image-but/22404/2) for further leads.

---

<div class="post-metadata">

**Author:** ![cchderrick](https://avatars.discourse-cdn.com/v4/letter/c/ecd19e/32.png) [@cchderrick](https://discourse.julialang.org/u/cchderrick)\
**Post date:** [June 14, 2021, 7:19pm UTC](https://discourse.julialang.org/t/fft-of-matrix-type-doesnt-work/62902/3 "2021-06-14T19:19:55Z")

</div>

The intro of the package:

```markdown
This package is mainly not intended to be used directly. Instead, developers of packages that implement FFTs (such as FFTW.jl or FastTransforms.jl) extend the types/functions defined in AbstractFFTs. This allows multiple FFT packages to co-exist with the same underlying fft(x) and plan_fft(x) interface.

```

Like @rafael.guerra said, you could use FFTW.

```julia
 using FFTW
img=[sin(2*pi*x*10/256) for x in 1:256, y in 1:256]
fft(img)

```
