Group Abstract Group Abstract

Message Boards Message Boards

0
|
9K Views
|
3 Replies
|
3 Total Likes
View groups...
Share
Share this post:

How to recreate a FourierDCT from phase and amplitude ?

Posted 12 years ago

Hi,

I have two stock tiff images called elaine and lena. Both are 8-bit 512x512. I am trying to show that phase caries more info than the amplitude by following Jim Fienup's slideshow from here: http://www.eecs.umich.edu/systems/FienupSeminar.pdf The code is relatively simple:

(* reading the two images in *) 
    elaineTiff = Import["elaine.tiff"];
    elaine = ImageData[ColorNegate[elaineTiff]]; 
    lenaTiff = Import["Lena.tiff"]; 
    lena = ImageData[ColorNegate[lenaTiff ]];

    (* Fourier tranform them and calculate amplitude and phase *) 
    elaineFt = FourierDCT[elaine]; 
    lenaFt = FourierDCT[lena]; 

    elaineFtAbs = Abs[elaineFt]; 
    lenaFtAbs = Abs[lenaFt]; 
    elaineFtPhase = Table[ArcTan[Im[elaineFt[[i, j]] ]/Re[elaineFt[[i, j]] ] ], {i, 1, Length[elaineFt]}, {j, 1, Length[elaineFt[[i]] ]}]; 
    lenaFtPhase =  Table[ArcTan[Im[lenaFt[[i, j]] ]/Re[lenaFt[[i, j]] ] ], {i, 1, Length[lenaFt]}, {j, 1, Length[lenaFt[[i]] ]}];

    (* then matching elaine amplitude to lena phase and vica verse and
     matching elaine amplitude to elaine phase and lena amplitude to lena phase *) 
    elaineFtAbslenaFtPhase = elaineFtAbs*Exp[I*lenaFtPhase ];
    lenaFtAbselaineFtPhase = lenaFtAbs*Exp[I*elaineFtPhase ];
    elaineFtAbselaineFtPhase = elaineFtAbs*Exp[I*elaineFtPhase ];
    lenaFtAbslenaFtPhase = lenaFtAbs*Exp[I*lenaFtPhase ];

    (* then using Fourier transform again to convert them back to image space *) 
    elainelena = FourierDCT[elaineFtAbslenaFtPhase]; 
    lenaelaine = FourierDCT[lenaFtAbselaineFtPhase]; 
    elaineelaine = FourierDCT[elaineFtAbselaineFtPhase]; 
    lenalena = FourierDCT[lenaFtAbslenaFtPhase];

    (* finally taking the Abs values and display them by Image *)
    {Image[Abs[elainelena] ], Image[Abs[lenaelaine]]}
     {Image[Abs[elaineelaine] ], Image[Abs[lenalena] ]}

I expected to see the original images on the last line, but I did not get that. What am I doing wrong?

Attachments:
POSTED BY: Janos Lobb
3 Replies
POSTED BY: Henrik Schachner

I had meant to mention that. What you might use is the two argument form of ArcTan, that is, ArcTan[x,y].

POSTED BY: Daniel Lichtblau
Posted 12 years ago

To tell the truth, I tried Fourier and InverseFourier before I tried FourierDCT. I think the real problem with my approach was in the phase calculation, because I took in all case the ArcTan[Im[z]/Re[z]] regardless of the sign of them. That was wrong. This line shows it clearly:

In[30]:= Table[
  ArcTan[Im[elaineFt[[i, j]] ]/Re[elaineFt[[i, j]] ] ], {i, 1, 
   Length[elaineFt]}, {j, 1, Length[elaineFt[[i]] ]}] === Arg[elaineFt]

Out[30]= False

Arg[z] probably has the right definition coded in.
Thanks a lot for your help, now I can go further. With the best, János

POSTED BY: Janos Lobb
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard