# 2D-FFT gives nonzero imaginary value at \[1,1\]

**URL:** https://discourse.julialang.org/t/2d-fft-gives-nonzero-imaginary-value-at-1-1/129500
**Category:** Signal and Image Processing
**Tags:** image-processing, fft
**Created:** [May 31, 2025, 10:57am UTC](https://discourse.julialang.org/t/2d-fft-gives-nonzero-imaginary-value-at-1-1/129500 "2025-05-31T10:57:19Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)
#### Post date: [May 31, 2025, 10:57am UTC](https://discourse.julialang.org/t/2d-fft-gives-nonzero-imaginary-value-at-1-1/129500/1 "2025-05-31T10:57:19Z")

</div>

Perhaps this is just my imperfect knowledge of how FFT works, but according to the theory, the Fourier transform at zero frequency of real-valued data is always real, and I thought that this should also happen with FFT. Now, that’s actually what I have always observed in 1D signals, and _usually_ with 2D data (images), but not always. For instance:

```julia-repl
julia> using Images, TestImages, FFTW

julia> chelsea = Gray.(testimage("chelsea.png"));

julia> first(fft(channelview(chelsea))) # expected: null imaginary part
63396.11f0 + 0.0f0im

julia> frame = fill(zero(Gray), 520, 530); # variation with a black frame

julia> frame[111:410, 40:490] .= chelsea;

julia> first(fft(channelview(frame))) # small, but nonzero imaginary part
63396.105f0 - 0.0016288757f0im

```

How is this? Am I ignoring some point of how FFT works, or am I doing something wrong?

---

<div class="post-metadata">

### Author: ![mgkuhn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mgkuhn/32/6276_2.png) [@mgkuhn](https://discourse.julialang.org/u/mgkuhn)
#### Post date: [May 31, 2025, 11:08am UTC](https://discourse.julialang.org/t/2d-fft-gives-nonzero-imaginary-value-at-1-1/129500/2 "2025-05-31T11:08:12Z")

</div>

```julia
eps(63396.105f0) = 0.00390625f0 > 0.0016288757f0

```

You are worrying about an imaginary component that is smaller than the floating-point resolution of your real component. Your result is in fact real-valued (within the resolution of the number type used).
