How to reconstruct an image from Real and Imaginary part?
22 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Walter Roberson
on 16 Dec 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.
More Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices 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!