How to reconstruct an image from Real and Imaginary part?
22 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Peter Phan
am 16 Dez. 2021
Bearbeitet: Peter Phan
am 16 Dez. 2021
Hi everyone,
I am very new to Matlab and image processing. I have an image of phantom('Modified Shepp-Logan',200).Then, I use Fourier transformation to extract the Real and the Imaginary. After all, I want to modify the Real part as well as the Imaginary part by multiply each of them with a weighting score.
The out put is look like this.
I would like to ask how do I do that?
Thank you
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 16 Dez. 2021
filename = 'cameraman.tif';
img = imread(filename);
fimg = fft2(img);
sfimg = fftshift(fftshift(fimg,2),1);
rsf = real(sfimg);
isf = imag(sfimg);
contour(rsf)
title('fft2 real part'); colorbar
contour(isf)
title('fft2 imaginary part'); colorbar
real_weights = rand(size(rsf));
real_weights = real_weights + flipud(real_weights) + fliplr(real_weights) + fliplr(flipud(real_weights));
imag_weights = rand(size(isf));
imag_weights = imag_weights + flipud(imag_weights) + fliplr(imag_weights) + fliplr(flipud(imag_weights));
contour(real_weights);
title('real weights'); colorbar();
contour(imag_weights);
title('imaginary weights'); colorbar();
mod_sreal = rsf .* real_weights;
mod_simag = isf .* imag_weights;
mod_real = fftshift(fftshift(mod_sreal,2),1);
mod_imag = fftshift(fftshift(mod_simag,2),1);
reconstructed_fimg = complex(mod_real, mod_imag);
reconstructed_img = ifft2(reconstructed_fimg);
whos
rr8 = uint8(real(reconstructed_img));
ri8 = uint8(imag(reconstructed_img));
imshow(rr8)
title('reconstructed after weights, real part')
imshow(ri8)
title('reconstructed after weights, imag part')
I fftshift the fft2 results in order to center the ffts; in theory the result should be symmetric.
I then construct random weights. The random weights must maintain the symmetric nature of the shifted data. The bit where I sum flipped versions of the weights is an attempt to get back a matrix that is symmetric against both diagonals. It looks like I did not succeed -- if I had succeeded then there would be no imaginary components in the reconstructed image.
1 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!