0
$\begingroup$

I have 2 images of the same scene, captured by different cameras. So they a bit displaced. As far as I can understood, phases of FFT contains info about image details. My goal is to take intensity from first image, details from second and produce enhanced highly detailed image with proper intensity.

I tried to solve problem as is - apply FFT for both images, take magnitudes from first image and phases from second and apply iFFT. But I didn't get what I want. Image looked corrupted, see below.

enter image description here

Then I tried to compute Phase correlation , align images and apply the algorithm described above again. Result was the same.

Is it possible to do what I want? May be I need to do some calculations in frequency domain, like phase shifting? Matlab code is highly appreciated!

$\endgroup$
  • $\begingroup$ May I ask why you insist on using a solely FFT-based method for this application? I assume other techniques would be more fruitful in your case. $\endgroup$ – M529 Apr 28 '16 at 18:28
  • $\begingroup$ @M529 The thing I do is a part of complex image enhancment algorithm. But I'm newbie in signal procesing and do experiments to clarify some things for better understanding. Besides my mentor told me to dig in direction of frequency domain for now. $\endgroup$ – Maxim Metelskiy May 3 '16 at 15:39
  • $\begingroup$ FFT is a valuable tool for image analysis and experimenting with it is a very good way to learn about its behaviour! You will get a feeling for the sensitivity of the FFT towards slight modifications of the phase. $\endgroup$ – M529 May 3 '16 at 16:07
2
$\begingroup$

What you want to do is impossible with your technique. The phase of an FFT does not provide the details of an image. Even if it did, why would it enhance an image, if you exchanged the "details" of both images without any calculation?

The phase of an FFT of an image mainly holds the structure information, i.e. how the frequencies contribute to the image (in terms of phase offsets). This is valid for fine and coarse structures in the image. The magnitude tells you, how much each frequency contributes to the image. This information is in most cases less important, as can be seen by the general shape of the 2D magnitude spectrum (many strong low frequency contributions and a rapid decay towards higher frequencies).

I assume, what you would like do do is more a quite complex problem to be solved in image space. You might want to look for publications and algorithms on super-resolution for your application.

$\endgroup$
  • $\begingroup$ let me ask, is it possible to shift phase of, for example, fist image base on Phase correlation. So first and second images would have aligned phases. And how it would influence spatial domain of image? $\endgroup$ – Maxim Metelskiy Apr 28 '16 at 15:14
  • $\begingroup$ You certainly can do that. A global phase shift, however, does not change anything meaningful. A linear phase shift in the frequency domain, however, is related to a translation in the image domain. Higher order phase shifts would therefore probably distort your image. Keep in mind, that in frequency domain all image pixels contribute to every point in frequency space. Hence, any change in frequency domain will in general affect the whole image. Also keep in mind that two different images (i.e. slight tilt in camera perspective) have very different frequency domains. $\endgroup$ – M529 Apr 28 '16 at 18:24
0
$\begingroup$

My partner wrote this code in an image processing class and it worked. I hoped you will find here a hint of what you did wrong:

Brad_X = fft2(double(Brad_pic));
Brad_X_shifted = fftshift(Brad_X);

Baboon_X = fft2(double(Baboon_pic));
Baboon_X_shifted = fftshift(Baboon_X);

Brad_phase  = angle(Brad_X);
Brad_amp    = abs(Brad_X);

Baboon_phase  = angle(Baboon_X);
Baboon_amp    = abs(Baboon_X);

Brad_exp_baboon = Brad_amp.*(exp(1i*Baboon_phase));
Baboon_exp_brad = Baboon_amp.*(exp(1i*Brad_phase));

Brad_exp_baboon_pic = abs(ifft2(Brad_exp_baboon));
Baboon_exp_brad_pic = abs(ifft2(Baboon_exp_brad));

    figure;
subplot(1,2,1); imshow(Brad_exp_baboon_pic,[]); title('Brad Amp, Baboon Phase');
subplot(1,2,2); imshow(Baboon_exp_brad_pic,[]); title('Baboon Amp, Brad Phase');

In case you were wondering, we are indeed taking a picture of Brad Pitt and a picture of a baboon and changing their phase and amplitude. The result is not perfect, but I wouldn't expect it to be perfect either.

$\endgroup$
0
$\begingroup$

If @GaiusJulius's code doesn't help then neither will this. It doesn't appear to have the same issues yours does. Can you share your original two images?

enter image description here


R Code Below

#30406

require("EBImage")

image_url <- "http://www.lhup.edu/~dsimanek/3d/stereo/sailboats.jpg"
image_file <- basename(image_url)

if (!file.exists(image_file))
{
  download.file(image_url,image_file)
}

library(jpeg)
image <- readJPEG(image_file)
dims <- dim(image)

i1 <- flip(t(image[,1:(dims[2]/2),1]))
i2 <- flip(t(image[,(dims[2]/2 + 1):dims[2],1]))

I1 <- fft(i1)
I2 <- fft(i2)

I3 <- abs(I1) * exp(1i*Arg(I2))
i3 <- abs(fft(I3, inverse = TRUE) / length(I3))

par(mfrow=c(2,2))
image(i1, col  = gray((0:32)/32), axes = FALSE)
title("Image 1")
image(i2, col  = gray((0:32)/32), axes = FALSE)
title("Image 2")
image(i3, col  = gray((0:32)/32), axes = FALSE)
title("1's amplitude, 2's phase")
$\endgroup$
  • $\begingroup$ Thanks for response. But this is the same algorithm as GaiusJulius sugested. I'm not sure, if I can share my samles because of NDA. Anyway M529 explained, why it is not possible to do what I want. $\endgroup$ – Maxim Metelskiy Apr 28 '16 at 15:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.