Reconstructing signal using the IFFT
21 views (last 30 days)
Show older comments
Hello, I am using the FFt to convert a time series signal into images by reshaping the matrix (N*N). But i am having hard time to get the original signal back from the images. IS it because in fft i am considering only the magnitude of the signal not the phase of the signal ? Is there any way to solve this proble. May be using STFT ot any kind of other techniques
0 Comments
Answers (2)
Mathieu NOE
on 24 Jan 2025
hello
try this (it works for images but also for any 2D numerical array)
output = input with minimal error :
max(abs(outpict - inpict),[],'all') = 1.5543e-15
filename = 'image.png';
inpict = im2double(rgb2gray(imread(filename)));
% take the 2D fft
spec_img = fftshift(fft2(inpict));
% generated backward the output image by inverse fft
outpict = real(ifft2(ifftshift(spec_img)));
figure(1)
subplot(2,1,1),imshow(inpict)
subplot(2,1,2),imshow(outpict)
13 Comments
William Rose
on 31 Jan 2025
@Opy,
This sounds like a good masters or PhD topic. Too much for a Matlab Answers discussion.
This also illustrates why it is good when asking a question on Matlab Answers to state what you're really after. You kind of did, but not much. I guess I should have pushed you for more info first, before spending time demonstrating stuff which, I now realize, was completely irrelevant.
"This is a rough idea I got from an article, but after starting the work, I am finding it very difficult..."
What article gave you a rough idea?
"I found a paper that clearly states other techniques are not suitable for my problem, as most of them are not scale-invariant and not invertible.(link)"
Is this preprint [Hellerman & Lessmann 2023] the article from which you got a rough idea? Hellerman & Lessmann (2023) describe the novel XIRP method for making an image from a 1D signal (eq. 8). They also describe other methods including GASF. Note that their methods generate an image with size SxS, where the original signal has S samples. That is very different from the stuff we did above, where we rearranged a signal of length S into an image of size sqrt(S) x sqrt(S), or 2*sqrt(S) x sqrt(S). Since invertibility is important to you, you need to udnerstand what the authors mean by "stochastic inversion", which they menton three times in their preprint. And you should implement the IM and IRC methods for inversion, which they discuss.
Hellermann & Lessmann 2023 goal, as stated in the ir introduction, seems very similar to yours. Therefore I reocmmnd that you understand their work fully. If it were me, I would reproduce many aspects of their preprint, to be sure you really understand. Note that XIRP only works on positive sequences. It follows from eq.8 that XIRP images are anti-symmetric.
"I only found a single paper where FFT and IFFT have been used, but the authors did not explain the method explicitly. (link)"
The Science Direct link to Hu et al., (2024) J Energy Storage, does not have the full paper. Have you read the full paper? They don't explain their methods in the full paper?
I have no expertise in this area. I reocmmend that you consult with someone who does.
William Rose
on 25 Jan 2025
Moved: William Rose
on 1 Feb 2025
@Opy,
fs=22050; % sampling rate (Hz)
t=0:1/fs:5;
y1=chirp(t,131,5,1048); % 3 octave chirp signal, 5 seconds long
% sound(y1,fs) % play it
M=round(sqrt(length(y1))); % find approximate square dimensions
N=floor(length(y1)/M);
img1=reshape(y1(1:M*N),M,N); % reshape to approximately square
imshow(img1)
img1fft = fftshift(fft2(img1));
% inverse fft
img2 = real(ifft2(ifftshift(img1fft)));
imshow(img2)
y2=reshape(img2,1,[]);
% sound(y2,fs) % play it
fprintf('max(abs(y2-y1))=%.2e.\n',max(abs(y2-y1(1:M*N))))
4 Comments
William Rose
on 2 Feb 2025
@Opy, I agree that the method of Hellerman & Lessman may not be practical for signals with thousands of points.
See Also
Categories
Find more on Transforms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!