bugGNU Octave - Bugs: bug #63094, FFT2 produces a result that...


bug #63094: FFT2 produces a result that differs from MATLAB

Submitter:  None
Submitted:  Fri 23 Sep 2022 12:15:38 PM UTC
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Works For Me Assigned to:  None
Originator Name:  STEPHEN E RANKIN Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 6.4.0
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup

Sun 02 Oct 2022 12:28:46 AM UTC, comment #4: 

No response in a week. Closing as Works for me.

@OP: If it's a bug in Octave it can be reopened. If you need help with your code not working as intended, try https://octave.discourse.group

Arun Giridhar <arungiridhar>
Group Member
Sat 24 Sep 2022 09:27:24 AM UTC, comment #3: 

Which version of the fftw libraries are you using?
What does `version -fftw` return for you?

Markus M├╝tzel <mmuetzel>
Group administrator
Fri 23 Sep 2022 06:59:49 PM UTC, comment #2: 

The code works for me on both Octave 6.4.0 and Octave 8, in addition to dasergatskov's 7.2.0. I get the same figure. Marking as Works for me.

@OP: Are you using Qt for graphics or something else? Does it make a difference if you disable hardware rendering before starting Octave?

Arun Giridhar <arungiridhar>
Group Member
Fri 23 Sep 2022 12:34:38 PM UTC, comment #1: 

It works on my octave 7.2 (on linux).

(See attached)


Dmitri A. Sergatskov <dasergatskov>
Fri 23 Sep 2022 12:15:38 PM UTC, original submission:  

The result of trying to differentiate a Gaussian by FFT fails on Octave running on Ubuntu 22.04, but works on MATLAB with the same code:

    size2 = 101;
    A = 10;
    sigma = 10;
    gauss = zeros(size2);

    for y = 1:size2
        for x = 1:size2
            size2/2)^2)); %gaussiana

    hf = fftshift(fft2(gauss));
    [U,V] = meshgrid(-50:50, -50:50);
    hf2 = (exp(1i*2*pi*U/101) - 1).*(exp(1i*2*pi*V/101) - 1).*hf;
    out_freq = real(ifft2(ifftshift(hf2)));
    out_freq = out_freq(1:end-1,1:end-1);
    out_spatial = diff(diff(gauss, 1, 1), 1, 2);
    imshow(out_spatial, []);
    title('Derivative from spatial domain');
    imshow(out_freq, []);
    title('Derivative from frequency domain');



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Attached Files
file #53745:  fft2_octave72.png added by dasergatskov (19KiB - image/png)
file #53743:  octave.jpg added by None (19KiB - image/jpeg)
file #53744:  matlab.jpg added by None (15KiB - image/jpeg)


Depends on the following items: None found

   bug dependencies.


Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by arungiridhar (Posted a comment)
  • -email is unavailable- added by dasergatskov (Updated the item)
  • -email is unavailable- added by None (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only project members can vote.


    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-10-02 arungiridhar Open/ClosedOpen Closed
    2022-09-23 arungiridhar StatusNone Works For Me
    2022-09-23 mmuetzel Dependencies- bugs #63093 is dependent
    2022-09-23 dasergatskov Attached File- Added fft2_octave72.png, #53745
    2022-09-23 None Attached File- Added octave.jpg, #53743
        Attached File- Added matlab.jpg, #53744

    Back to the top

    Powered by Savane 3.12