2

I have computed magnitude and phase spectrum of cameraman Gray scale image using fft function. Here, we get magnitude and phase spectrum of the whole image. .Please see the reconstruction of image from phase only part from the accepted answer of Image Reconstruction:Phase vs Magnitude which says that in an image neighboring pixels of the edge,lines and corner are in phase . So I want to find phase values on precise pixels

Given an image of dimensions 256*256, how can I find phase values of pixels at locations(100,121),(100,122) and (100,123) ?

Whether it is possible using Fourier Transform or not? If not ,what is the other way to do it? Can anybody explain it with (or without ) code?

enter image description hereenter image description here

clc;
clear all;
close all;

i=imread('C:\Users\RK\Desktop\cameraman.gif');
%i=rgb2gray(i);
i=uint8(i);

figure,
subplot(1,3,1);imshow(i);
title('Cameraman Gray scale Image');

f1=fft2(i);
f2=log(1+fftshift(f1));


m=abs(f2);
subplot(1,3,2);
imshow(m,[]);
title('Magnitude Spectrum');  

phase=angle(f2);
subplot(1,3,3);a
imshow(phase,[]);
title('Phase Spectrum');
devraj
  • 407
  • 1
  • 4
  • 12
  • You can't find the precise phase value of a given pixel because of the uncertainty principle. You can only find the phase value for the pixel's neighborhood using short-time Fourier tranform. If you want to know the phase for pixel (100,100), ou have to take a neighborhood, for instance (50:150,50:150) and calculate the 2D Fourier transform on this window. @devraj you have also asked questions on DSP stack exhange, most of them have received good answers, please mark them as answered if they were helpfull to you. – Antoine Bassoul Apr 30 '15 at 13:10
  • @Antoine Bassoul thanks for your feedback.Do you have any code or output results to compute phase value on any precise pixel locations. – devraj May 01 '15 at 09:40
  • @Yves Daoust sir, How can you find phase values at certain pixel locations with the help of wavelet transform ? – devraj May 01 '15 at 09:42
  • The only consistent definition of phase for a single pixel would be the phase of the complex value at that pixel. Since your image data is real and even non-negative, the phase value at all pixels is precisely 0. – Jazzmaniac May 01 '15 at 09:43
  • @devraj It's a bit cumbersome to write a full tutorial answer about short time fourier transform considering you are a beginer in signal processing, I don't have too much time at the moment. I advice you to check short time fourier transform by yourself, on a practical point of view it is realy just about calculating the fourier transform on a window around your point of interest. More complex issues arises from the window selection and the window's effect on the spectrum. – Antoine Bassoul May 01 '15 at 09:45
  • @Jazzmaniac sir,anyhow i want to compute phase values by any method. this image was just taken as an example. You can take image of your choice and show me how to compute phase value at pixel locations. – devraj May 01 '15 at 09:49
  • @Yves Daoust ok my main aim is to find phase values at pixel locations of edges,corners. I have read that in an image edge ,lines and corner are in phase. I wanted to actually see this. So my any means u can explain me. using fourier or using wavelet. – devraj May 01 '15 at 09:55
  • @ Antoine Bassoul sir i have gone through short time Fourier transform but I dont understand how to do coding for it. But i need it so much. so if it is not possible to you right now, u can give the solution when u get time. is it ok? – devraj May 01 '15 at 10:02
  • @Yves Daoust u can refer answer of dsp.stackexchange.com/questions/16995/image-reconstructionphase-vs-magnitude – devraj May 01 '15 at 10:05
  • @devraj take a windows around your point of interest, for instance the windows (50:150,50:150) for the point (100,100). Use regular 2D fourier transform on this window, and voila, you have the phase of your point. I let you dive the issues of resolution, uncertainty etc ... But as it has been said, I don't know what you'll do with this phase spectrum, it is likely that it won't have any interpretation. – Antoine Bassoul May 01 '15 at 10:26
  • @devraj, you're not getting the point. The only answer for the phase of a single pixel of an image can be 0. There is no other way to calculate it unless you expand some neighbourhood of the pixel with a basis that has a meaningful phase definition. And such an expansion is greatly arbitrary and not just "one pixel". So unless you explain what you're really trying to achieve you already have been given the only meaningful answer. – Jazzmaniac May 01 '15 at 11:20
  • @Jazzmaniac sir please refer the link attached in my question. How can we see in phase pixels using wavelet/fourier transform or in matlab/opencv – devraj May 01 '15 at 11:32
  • @devraj, that link does not help me in any way to clarify what you're really asking. Also there is no such thing as "in phase pixels", unless you're able to give a proper definition. This also has nothing to do with the phase of a single pixel. You should rephrase your question without including false assumptions like you obviously do. You seem to have problems of understanding at a much more basic level which you should try to identify. – Jazzmaniac May 01 '15 at 13:20
  • @Jazzmaniac Sir I wanted to find phase values at pixel locations of edges,corners. I have read that in an image edge ,lines and corner are in phase.plz see the answer from the link. I wanted to actually see this. So by any means u can explain me. using fourier or using wavelet. – devraj May 01 '15 at 13:44
  • @devraj, you have misunderstood that statement. It's not about the phases of the pixels in the image, it's about the phases of a basis function definition. When you reconstruct the image from a Fourier decomposition, the Fourier basis vectors have a complex phase at each pixel. Depending on whether the phases of the basis functions line up at a point, the amplitude of the reconstruction is large or small. Sharp edges in the reconstructed image require certain line up of the basis function phases. Such features can be called "phase coherent". – Jazzmaniac May 01 '15 at 18:22
  • @Antoine Bassoul sir i have edited my question. It will clear that what i really want. – devraj May 01 '15 at 19:03
  • @Jazzmaniac thank you very much for your feedback.But as you said " Sharp edges in the reconstructed image require certain line up of the basis function phases. Such features can be called "phase coherent" " .

    My question is to you why these basis function phases line up at edges or corner pixel locationonly.?Why not at other pixels location?

    Also,are there any mathematical computations available to understand "phase coherent" concept?

    – devraj May 01 '15 at 19:17
  • The Fourier basis functions have the same magnitude everywhere. So if you want to create very large of very small values locally, the basis functions must interfere constructively or destructively. And that means they must agree in terms of phase. If you want to really understand this, study Fourier analysis very carefully. This takes time and requires patience, but the insight will come to you. – Jazzmaniac May 01 '15 at 20:45

1 Answers1

-1

You can't find the precise phase value of a given pixel because of the uncertainty principle. You can only find the phase value for the pixel's neighborhood using short-time Fourier tranform.

If you want to know the phase for pixel (100,100), ou have to take a neighborhood, for instance (50:150,50:150) and calculate the 2D Fourier transform on this window.

Antoine Bassoul
  • 444
  • 2
  • 8