FFT Combination of Two Images
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am trying to take two simple images (a horizontal slit and a vertical slit), take the fft2 of each individual image, combine the fft2 version of the two images using some sort of operation to make a single fft2 image, then take the ifft2 of that combined image to get a new original image of the horizontal and vertical slits combined. I am stuck on the combining operation. I've tried 'or' and 'bitor' but it's not quite working. The ifft2 does not result in the correct image. Someone please help!
Here is my attempt at the code:
horz = zeros(16, 16);
horz(:, 8-2:8+2) = 255.;
vert = zeros(16, 16);
vert(8-2:8+2, :) = 255.;
f_horz = fft2(horz);
f_horzshift = fftshift(f_horz);
f_vert = fft2(vert);
f_vertshift = fftshift(f_vert);
bitorop = bitor(f_horzshift, f_vertshift);
inverse = ifft2(bitorop);
surf (abs(inverse))
2 commentaires
Geoff Hayes
le 3 Juil 2015
John - when I run your above code, I observe the following error
Error using bitor
Inputs must be real.
which makes sense since your f_horzshift and f_vertshift involve complex numbers.
Since the Fourier transform is linear, then why not just add the two
inverse = ifft2(f_horzshift + f_vertshift);
Why choose bit operations over the above? And what is the correct image?
Réponses (1)
Image Analyst
le 3 Juil 2015
No, you don't do that at all. That would not make any physical sense. What are you trying to do anyway? Do you want the FT of the product of the vertical slit and a horizontal slit? If so, you know that multiplication in one domain is convolution in the other domain, not anything with bit processing.
5 commentaires
Image Analyst
le 4 Juil 2015
You can set a matrix value with indexing and assignment
yourMatrix(row, column) = newValue;
But I don't know why you're adding two spectra. And then why you're changing some of the values like that. It doesn't seem to be what you should be doing in Fourier filtering. Maybe you can explain the theoretical basis for this kind of filtering.
Voir également
Catégories
En savoir plus sur Frequency Transformations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!