effects of ifft2(x, 'symmetric') while x is not conjugate symmetric

129 visualizzazioni (ultimi 30 giorni)
Hi all,
I understand that 'symmetric' in ifft2 assumes data is conjugate symmetric and will output real values, but I want to know how exactly is this done. Specifically:
  1. with 'symmetric', will only half of the data be used or still the whole matrix is used, but just output real values?
  2. if x is not conjugate symmetric but I still pass in 'symmetric', what will happen?
Thanks in advance.

Risposta accettata

Matt J
Matt J il 23 Nov 2025 alle 1:44
Modificato: Matt J il 23 Nov 2025 alle 1:45
When you specify "symmetric", the upper half of the fft input array is ignored, e.g.
x=ones(1,7);
ifft(x)
ans = 1×7
1.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
x(5:end)=rand(1,3); %write random junk into the upper half of x
ifft(x)
ans =
0.8258 + 0.0000i 0.0750 + 0.0982i -0.0516 - 0.0461i 0.0637 + 0.1255i 0.0637 - 0.1255i -0.0516 + 0.0461i 0.0750 - 0.0982i
ifft(x,'symmetric')
ans = 1×7
1.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
  4 Commenti
Paul
Paul il 23 Nov 2025 alle 2:55
I don't think that's true for the rows that aren't in the first column.
X = ifft2(rand(10));
x1 = ifft2(X,'symmetric');
X(end,3) = 0;
x2 = ifft2(X,'symmetric');
isequal(x1,x2)
ans = logical
0
Matt J
Matt J il 23 Nov 2025 alle 14:19
Modificato: Matt J il 23 Nov 2025 alle 14:37
Yep, my bad. In higher dimensions, conjugate symmetry means the image is symmetric across the origin. So, if you view the array after fftshift(), the cells it would be using are the right half, minus half of one of the DC axes. In other words, it needs cells from two quadrants to cover the whole array by symmetry, and also only the non-negative DC axes are needed.
If you re-organize this in terms of the original ordering of X(i,j) it means the cells that can be discarded are the light-shaded ones below, which is consistent with what @Paul found in his tests:

Accedi per commentare.

Più risposte (1)

Paul
Paul il 23 Nov 2025 alle 2:24
Modificato: Paul il 23 Nov 2025 alle 16:44
It appears that only portions of the input matrix are used when 'symmetric' is specified on input to ifft2 and the input is 2D
rng(100);
X = rand(10,12) + 1j*rand(10,12); % non-symmetric input
x1 = ifft2(X,'symmetric');
X(:,8:12) = 0; % zero out the entire right side
X(7:10,1) = 0; % zero out the top half of the first column
x2 = ifft2(X,'symmetric');
isequal(x1,x2)
ans = logical
1
  20 Commenti
Paul
Paul circa 2 ore fa
Why would Case 2 be considered a bug but not Cases 1 and 3?
Or maybe Cases 1 and 3 could be considered as a distinctly different issue than Case 2; the issue being that ifft2 doesn't return the same output for the same input being 2D or a slice of ND? Are you o.k. with the behavior of Cases 1 and 3?
BTW, I don't really have a dog in this hunt because, IIRC, I've never used fft2/ifft2 in anger, so I'm quite interested in other's opinions of those functions' functionality.
Matt J
Matt J circa un'ora fa
Modificato: Matt J circa un'ora fa
So, just to be clear, I don't judge whether a bug is in play based solely on input/output. I'm judging it also based on how we know the data is processed in each of these cases. We haven't really been able to identify anything improper about how the processing is done when symflag='nonsymmetric' within ifft2.m. There are discrepancies in the outputs of the Case 1 and Case 3 tests, but those appear to arise from normal floating point precision noise.
Conversely, we have identified impropriety in the way symflag='symmetric' is processed when X is 3D or higher and Case 4 exposes that. I consider the bug to be in play in Case 2 as well, because the data is being processed in the same incorrect wasy as in Case 4. Granted, the test in Case 2 doesn't expose the bug - you are again getting agreement within float precision. But that's only because, with an already-symmetric X as input, it's an uninformative test. It doesn't mean the processing is being done properly.

Accedi per commentare.

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by