Skip to main content

[JAI] Frequency Ops, DFT, IDFT

15 replies [Last post]
Anonymous

Hi, My question is about InverseDFT

In most other imaging packages example Matalab, there is a choice to
perform InverseDFT or InverseFFT using either ONLY the magnitude or ONLY
the phase or both magnitude and phase together as a complex image and
lot other variations like magnitude with random phase or magnitude with
gaussian phase

In JAI there is an option to specify DFTDataNature.COMPLEX_TO_REAL,
COMPLEX_TO_COMPLEX or REAL_TO_COMPLEX but am not sure it works

for a complex X+iY, MAG = R = SQRT(X*X + Y*Y) and PHASE=THETA==Y/X
or conversely
X = R*COS(THETA) and Y=R*SIN(THETA)

The problem I am having at the moment, if I want to compute IDFT using
only Magnitude, then I can provide a ZERO phase image in which case the
complex image (for IDFT) becomes
X=R*1 and Y=0 (This isnt right)

if I want to use only the phase image for IDFT, I can provide a ZERO mag
image but
X=0 and Y=0 as R=0, but when I use R=1 (all pixels in image is 1) then
my IDFT output doesnt work out right

But all works fine if iI use both magnitude and phase and the same
images work with matlab n other packages....How does REAL_TO_COMPLEX
IDFT work? what is taken as the real input image? and what is the output
COMPLEX image? Any ides how I cna get only magnitude, only phase IDFT to
work?

I hv magnitude and Random phase workin by simply substituting the phase
image with a random phase image...but doesnt work for NO phase

Any help? pointers?

--
Mahalingam Gopalan
Texture Lab 1.69 / G29
School of Mathematics and Computer Science
Heriot-Watt University

If we knew what it was we were doing, it would not be called research,
would it?
- Albert Einstein

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai-imageio.dev.java.net
For additional commands, e-mail: interest-help@jai-imageio.dev.java.net

--
Mahalingam Gopalan
Texture Lab 1.69 / G29
School of Mathematics and Computer Science
Heriot-Watt University

If we knew what it was we were doing, it would not be called research,
would it?
- Albert Einstein

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Brian Burkhalter

This problem has been filed as jai-core issue 19:

https://jai-core.dev.java.net/issues/show_bug.cgi?id=19

Brian

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Brian Burkhalter

So for steps 2 and 3 what exactly are you doing? For step 2 I would expect
that you would do this

IDFT(PolarToComplex(Magnitude(DFT(F)),Constant(0)))

and for 3 this

IDFT(PolarToComplex(Constant(1),Phase(DFT(F))))

Without a priori information I would assume the output of either to be complex
and that the magnitude of the output would have to be what is displayed.

Brian

On Fri, 27 May 2005, Mahalingam Gopalan wrote:

> Hi Brian,
>
> Apologies for the delay in getitng back to you...This is part of a
> coursework description for my postgraduate study a couple of years ago
> and the course is still running :-)
>
> Description
> You are asked to write a MATLAB program to perform the following tasks
> for each of the given test images Lena.jpg and Beckman.jpg:
>
> //FINE
> 1. Compute the DFT F(x; y) and display the magnitude and phase of F(x; y).
> //PROBLEM 2, 3
> 2. Keep the magnitude of F(x; y) and set the phase to 0 for each
> frequency sample. Take the inverse DFT and compare the results to the
> original image.
> 3. Keep the phase of F(x; y) and set the magnitude to unity for each
> frequency sample. Take the inverse DFT and compare the results to the
> original image.
> //FINE
> 4. Keep the phase of F(x; y) and replace the magnitude of each frequency
> sample by its square root. Take the inverse DFT and compare the results
> to the original image. You should observe an edge enhancement.
>
> Hint: You will need to use the following functions: imread, fft2, ifft2,
> fftshift, abs, angle.
>
> The function descriptions of MATALAB
> http://www.mathworks.com/access/helpdesk/help/techdoc/ref/ifft2.html
>
> Nick Efford http://www.comp.leeds.ac.uk/nde/book/index.html
> has a set of classes that include ImageFFT which extends the
> functionality of Java 2D and his custom FFT implementation
> and I used that before switching to JAI
>
> The output images from ImageFFT and MATALAB, for Steps 2 & 3 are OK but
> the ones from JAI are NOT
>
> Cheers!

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Mahalingam Gopalan

Hi Brian,

Yeah..thats exactly what I am doing...with inconsistent output images

Am attaching a java file..This is a collection of methods in various
classes within a framework but its a working version

Cant figure out what I am doing wrong

Thankx for ur help n feedback

Brian Burkhalter wrote:

>So for steps 2 and 3 what exactly are you doing? For step 2 I would expect
>that you would do this
>
> IDFT(PolarToComplex(Magnitude(DFT(F)),Constant(0)))
>
>and for 3 this
>
> IDFT(PolarToComplex(Constant(1),Phase(DFT(F))))
>
>Without a priori information I would assume the output of either to be complex
>and that the magnitude of the output would have to be what is displayed.
>
>Brian
>
>On Fri, 27 May 2005, Mahalingam Gopalan wrote:
>
>
>
>>Hi Brian,
>>
>>Apologies for the delay in getitng back to you...This is part of a
>>coursework description for my postgraduate study a couple of years ago
>>and the course is still running :-)
>>
>>Description
>>You are asked to write a MATLAB program to perform the following tasks
>>for each of the given test images Lena.jpg and Beckman.jpg:
>>
>>//FINE
>>1. Compute the DFT F(x; y) and display the magnitude and phase of F(x; y).
>>//PROBLEM 2, 3
>>2. Keep the magnitude of F(x; y) and set the phase to 0 for each
>>frequency sample. Take the inverse DFT and compare the results to the
>>original image.
>>3. Keep the phase of F(x; y) and set the magnitude to unity for each
>>frequency sample. Take the inverse DFT and compare the results to the
>>original image.
>>//FINE
>>4. Keep the phase of F(x; y) and replace the magnitude of each frequency
>>sample by its square root. Take the inverse DFT and compare the results
>>to the original image. You should observe an edge enhancement.
>>
>>Hint: You will need to use the following functions: imread, fft2, ifft2,
>>fftshift, abs, angle.
>>
>>The function descriptions of MATALAB
>>http://www.mathworks.com/access/helpdesk/help/techdoc/ref/ifft2.html
>>
>>Nick Efford http://www.comp.leeds.ac.uk/nde/book/index.html
>>has a set of classes that include ImageFFT which extends the
>>functionality of Java 2D and his custom FFT implementation
>> and I used that before switching to JAI
>>
>>The output images from ImageFFT and MATALAB, for Steps 2 & 3 are OK but
>>the ones from JAI are NOT
>>
>>Cheers!
>>
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
>For additional commands, e-mail: interest-help@jai.dev.java.net
>
>
>

--
Mahalingam Gopalan
Texture Lab 1.69 / G29
School of Mathematics and Computer Science
Heriot-Watt University

If we knew what it was we were doing, it would not be called research,
would it?
- Albert Einstein
[TestFreq.java]
---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Brian Burkhalter

I don't see any glaring errors in there but I think that it is insufficient to
solve the problem. Could you send a self-contained standalone test case and
include the source image as well as the expected result images?

Thanks,

Brian

On Wed, 1 Jun 2005, Mahalingam Gopalan wrote:

> Yeah..thats exactly what I am doing...with inconsistent output images
>
> Am attaching a java file..This is a collection of methods in various
> classes within a framework but its a working version
>
> Cant figure out what I am doing wrong
>
> Thankx for ur help n feedback

----------------
Brian Burkhalter
Advanced Development, Graphics and Media
Software Chief Technology Office
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Mahalingam Gopalan

In javax.media.jai.ImageFunction.getElements(...) the documentation does
NOT explain the parameter int element,

http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/ja...

When I implement, am I supposed to use that in some way?

Just to bring to your notice

Cheers!
--
Mahalingam Gopalan
Texture Lab 1.69 / G29
School of Mathematics and Computer Science
Heriot-Watt University

If we knew what it was we were doing, it would not be called research,
would it?
- Albert Einstein

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Brian Burkhalter

"element" is the zero-relative index of the complex element at issue. So if
each pixel has N components then 'element' can take on the value 0,...,N-1.
The complex sample at each index will have a real and imaginary component.

Brian

https://jai-core.dev.java.net/issues/show_bug.cgi?id=19

On Fri, 27 May 2005, Mahalingam Gopalan wrote:

> In javax.media.jai.ImageFunction.getElements(...) the documentation does
> NOT explain the parameter int element,
>
> http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/ja...
>
> When I implement, am I supposed to use that in some way?
>
> Just to bring to your notice
>
> Cheers!

----------------
Brian Burkhalter
Advanced Development, Graphics and Media
Software Chief Technology Office
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Emmanouil Darakis

Hello,
I'm a newbie working on something similar.
I'm trying to multiply a grey scale image (loaded from a local bmp file) by
a one element (complex) ImageFunction which I have already calculated, and
then, further process the result (calculate its DFT etc).
In what way should I convert the original image and/or the real and
imaginary parts of the ImageFunction so that their complex multiplication is
possible?

Regards,
Manos

-----Original Message-----
From: Brian Burkhalter [mailto:Brian.Burkhalter@Sun.COM]
Sent: Friday, June 03, 2005 8:32 PM
To: interest@jai.dev.java.net
Subject: Re: [JAI] ImageFunction

"element" is the zero-relative index of the complex element at issue. So if
each pixel has N components then 'element' can take on the value 0,...,N-1.
The complex sample at each index will have a real and imaginary component.

Brian

https://jai-core.dev.java.net/issues/show_bug.cgi?id=19

On Fri, 27 May 2005, Mahalingam Gopalan wrote:

> In javax.media.jai.ImageFunction.getElements(...) the documentation does
> NOT explain the parameter int element,
>
>
http://java.sun.com/products/java-media/jai/forDevelopers/jai-apidocs/ja...
media/jai/ImageFunction.html
>
> When I implement, am I supposed to use that in some way?
>
> Just to bring to your notice
>
> Cheers!

----------------
Brian Burkhalter
Advanced Development, Graphics and Media
Software Chief Technology Office
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Brian Burkhalter

You would need to pad the 1-band grayscale image to two bands possibly using
the BandCombine operation with a 2x2 matrix {{1.0, 0.0},{0.0,0.0}}.

Brian

On Fri, 3 Jun 2005, Emmanouil Darakis wrote:

> I'm a newbie working on something similar.
> I'm trying to multiply a grey scale image (loaded from a local bmp file) by
> a one element (complex) ImageFunction which I have already calculated, and
> then, further process the result (calculate its DFT etc).
> In what way should I convert the original image and/or the real and
> imaginary parts of the ImageFunction so that their complex multiplication is
> possible?

----------------
Brian Burkhalter
Advanced Development, Graphics and Media
Software Chief Technology Office
Sun Microsystems, Inc.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any
unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

toufou
Offline
Joined: 2005-06-10

Please, I am reading you Brian, and you seem to be good in solving some problems. Can you watch my subject on "DFT and Zoom" please ?
I really need some help.
Thank you a lot if you can help me.

Nicolas.

P.S.: excuse me for my english, i am french ;)

Brian Burkhalter

On Mon, 13 Jun 2005 jai-interest@javadesktop.org wrote:

> Please, I am reading you Brian, and you seem to be good in solving some problems. Can you watch my subject on "DFT and Zoom" please ?
> I really need some help.
> Thank you a lot if you can help me.

Please see my earlier response.

> P.S.: excuse me for my english, i am french ;)

Excusez-moi de mon francais puisque je suis californien. ;-)

A+

Brian

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Brian Burkhalter

For the sake of argument let's assume we are dealing here with one-dimensional
real or complex data. In JAI we represent a single dimension of complex data
by two image bands where the band at index 0 is real and that at index 1 is
imaginary.

The DFTDataNature constants serve to indicate to the operation the nature of
the data involved. For example, if you were implementing the convolution of a
real image with a real kernel you might apply the DFT to each as
REAL_TO_COMPLEX, do a complex multiplication, and then apply an IDFT to the
result as COMPLEX_TO_REAL.

Brian

On Thu, 19 May 2005, Mahalingam Gopalan wrote:

> Hi, My question is about InverseDFT
>
> In most other imaging packages example Matalab, there is a choice to
> perform InverseDFT or InverseFFT using either ONLY the magnitude or ONLY
> the phase or both magnitude and phase together as a complex image and
> lot other variations like magnitude with random phase or magnitude with
> gaussian phase
>
> In JAI there is an option to specify DFTDataNature.COMPLEX_TO_REAL,
> COMPLEX_TO_COMPLEX or REAL_TO_COMPLEX but am not sure it works
>
> for a complex X+iY, MAG = R = SQRT(X*X + Y*Y) and PHASE=THETA==Y/X
> or conversely
> X = R*COS(THETA) and Y=R*SIN(THETA)
>
> The problem I am having at the moment, if I want to compute IDFT using
> only Magnitude, then I can provide a ZERO phase image in which case the
> complex image (for IDFT) becomes
> X=R*1 and Y=0 (This isnt right)
>
> if I want to use only the phase image for IDFT, I can provide a ZERO mag
> image but
> X=0 and Y=0 as R=0, but when I use R=1 (all pixels in image is 1) then
> my IDFT output doesnt work out right
>
> But all works fine if iI use both magnitude and phase and the same
> images work with matlab n other packages....How does REAL_TO_COMPLEX
> IDFT work? what is taken as the real input image? and what is the output
> COMPLEX image? Any ides how I cna get only magnitude, only phase IDFT to
> work?
>
> I hv magnitude and Random phase workin by simply substituting the phase
> image with a random phase image...but doesnt work for NO phase
>
> Any help? pointers?

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Mahalingam Gopalan

Hi Brian, Thanx for that...I figured as much but unfortunately that
doesnt answer my question...I hope am explaining my problem a bit
clearly here

//This is fine
Input Image -> DFT -> Complex Image ->IDFT (COMPLEX_TO_REAL) -> Outut
Image (same as input)

//Second process
Step1 Input Image -> DFT -> Complex Image ->Split into Mag (REAL)
and Phase (REAL) images //this is fine
//Here is my problem
Step2 Mag Image (from Step1) -> IDFT (DFTNature---WHAT?) -> Image
similar to input image with NO phase information //HOW TO?
Step3 Phase Image (from Step1) -> IDFT (DFTNature---WHAT?) -> Image
similar to input image with NO magnitude information //HOW TO?

//This is fine
Step4 Generate Random Phase Image-> PolarToComplex (Mag Image from
Step1 AND Generated RANDOM Phase) -> Complex Image -> IDFT
(COMPLEX_TO_REAL) -> REAL Output Image

My problem is at Step 2 and 3.

I hv tried using REAL_TO_COMPLEX
Step2 Mag Image (from Step1) -> IDFT (REAL_TO_COMPLEX) -> Complex
Output Image ->Split into Mag and Phase (Neither Mag nor phase
consistent with results from Matalab or other APIs)
Step3 Phase Image (from Step1) ->REAL_TO_COMPLEX) Same process as
above ->(Neither Mag nor phase consistent with results from Matalab or
other APIs)

I hv tried using COMPLEX_TO_REAL...similar to Step4 BUT...I use a blank
image with all pixels set to ZERO
Step2 Generate ZERO Phase Image-> PolarToComplex (Mag Image from
Step1 AND ZERO Phase) -> Complex Image -> IDFT (COMPLEX_TO_REAL) ->
Output Inconsistent with Matalab
Step3 Generate ZERO Mag Image -> PolarToComplex (ZERO Mag Image AND
Phase from Step 1) -> Complex Image -> IDFT (COMPLEX_TO_REAL) -> Output
Inconsistent with Matalab

I *know* how the output should look if I have
*only* mag info
*only* phase info
*random* phase with original mag

But I am not able to get the results using JAI but with the same input
image I hv correct verified results from Matalab but the rest of my
software is using JAI

Thank for your time....

Brian Burkhalter wrote:

>For the sake of argument let's assume we are dealing here with one-dimensional
>real or complex data. In JAI we represent a single dimension of complex data
>by two image bands where the band at index 0 is real and that at index 1 is
>imaginary.
>
>The DFTDataNature constants serve to indicate to the operation the nature of
>the data involved. For example, if you were implementing the convolution of a
>real image with a real kernel you might apply the DFT to each as
>REAL_TO_COMPLEX, do a complex multiplication, and then apply an IDFT to the
>result as COMPLEX_TO_REAL.
>
>Brian
>
>On Thu, 19 May 2005, Mahalingam Gopalan wrote:
>
>
>
>>Hi, My question is about InverseDFT
>>
>>In most other imaging packages example Matalab, there is a choice to
>>perform InverseDFT or InverseFFT using either ONLY the magnitude or ONLY
>>the phase or both magnitude and phase together as a complex image and
>>lot other variations like magnitude with random phase or magnitude with
>>gaussian phase
>>
>>In JAI there is an option to specify DFTDataNature.COMPLEX_TO_REAL,
>>COMPLEX_TO_COMPLEX or REAL_TO_COMPLEX but am not sure it works
>>
>>for a complex X+iY, MAG = R = SQRT(X*X + Y*Y) and PHASE=THETA==Y/X
>>or conversely
>>X = R*COS(THETA) and Y=R*SIN(THETA)
>>
>>The problem I am having at the moment, if I want to compute IDFT using
>>only Magnitude, then I can provide a ZERO phase image in which case the
>>complex image (for IDFT) becomes
>>X=R*1 and Y=0 (This isnt right)
>>
>>if I want to use only the phase image for IDFT, I can provide a ZERO mag
>>image but
>>X=0 and Y=0 as R=0, but when I use R=1 (all pixels in image is 1) then
>>my IDFT output doesnt work out right
>>
>>But all works fine if iI use both magnitude and phase and the same
>>images work with matlab n other packages....How does REAL_TO_COMPLEX
>>IDFT work? what is taken as the real input image? and what is the output
>>COMPLEX image? Any ides how I cna get only magnitude, only phase IDFT to
>>work?
>>
>>I hv magnitude and Random phase workin by simply substituting the phase
>>image with a random phase image...but doesnt work for NO phase
>>
>>Any help? pointers?
>>
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
>For additional commands, e-mail: interest-help@jai.dev.java.net
>
>
>

--
Mahalingam Gopalan
Texture Lab 1.69 / G29
School of Mathematics and Computer Science
Heriot-Watt University

If we knew what it was we were doing, it would not be called research,
would it?
- Albert Einstein

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Brian Burkhalter

Hello.

You indicated somewhere that you were also using Matlab so I guess you want to
get the same results with JAI. Do you have a mathematical statement of what
Matlab is doing for the inverse Fourier transform of the magnitude-only image?

My complex analysis is a bit stale but I would expect that if you are trying
to do

IDFT(Magnitude(DFT(image)))

then you would end up in most cases with a complex-valued image in which case
you would use the REAL_TO_COMPLEX setting. Note that if you are starting with
a single-band real image then using REAL_TO_COMPLEX should give you the same
result as if you were starting from a 2-band image with the first band being
the single-band image and the second band zero and using the
COMPLEX_TO_COMPLEX setting.

Brian

On Fri, 20 May 2005, Mahalingam Gopalan wrote:

> Hi Brian, Thanx for that...I figured as much but unfortunately that
> doesnt answer my question...I hope am explaining my problem a bit
> clearly here
>
> //This is fine
> Input Image -> DFT -> Complex Image ->IDFT (COMPLEX_TO_REAL) -> Outut
> Image (same as input)
>
> //Second process
> Step1 Input Image -> DFT -> Complex Image ->Split into Mag (REAL)
> and Phase (REAL) images //this is fine
> //Here is my problem
> Step2 Mag Image (from Step1) -> IDFT (DFTNature---WHAT?) -> Image
> similar to input image with NO phase information //HOW TO?
> Step3 Phase Image (from Step1) -> IDFT (DFTNature---WHAT?) -> Image
> similar to input image with NO magnitude information //HOW TO?
>
> //This is fine
> Step4 Generate Random Phase Image-> PolarToComplex (Mag Image from
> Step1 AND Generated RANDOM Phase) -> Complex Image -> IDFT
> (COMPLEX_TO_REAL) -> REAL Output Image
>
> My problem is at Step 2 and 3.
>
> I hv tried using REAL_TO_COMPLEX
> Step2 Mag Image (from Step1) -> IDFT (REAL_TO_COMPLEX) -> Complex
> Output Image ->Split into Mag and Phase (Neither Mag nor phase
> consistent with results from Matalab or other APIs)
> Step3 Phase Image (from Step1) ->REAL_TO_COMPLEX) Same process as
> above ->(Neither Mag nor phase consistent with results from Matalab or
> other APIs)
>
> I hv tried using COMPLEX_TO_REAL...similar to Step4 BUT...I use a blank
> image with all pixels set to ZERO
> Step2 Generate ZERO Phase Image-> PolarToComplex (Mag Image from
> Step1 AND ZERO Phase) -> Complex Image -> IDFT (COMPLEX_TO_REAL) ->
> Output Inconsistent with Matalab
> Step3 Generate ZERO Mag Image -> PolarToComplex (ZERO Mag Image AND
> Phase from Step 1) -> Complex Image -> IDFT (COMPLEX_TO_REAL) -> Output
> Inconsistent with Matalab
>
> I *know* how the output should look if I have
> *only* mag info
> *only* phase info
> *random* phase with original mag
>
> But I am not able to get the results using JAI but with the same input
> image I hv correct verified results from Matalab but the rest of my
> software is using JAI
>
> Thank for your time....

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Mahalingam Gopalan

Hi Brian,

Apologies for the delay in getitng back to you...This is part of a
coursework description for my postgraduate study a couple of years ago
and the course is still running :-)

Description
You are asked to write a MATLAB program to perform the following tasks
for each of the given test images Lena.jpg and Beckman.jpg:

//FINE
1. Compute the DFT F(x; y) and display the magnitude and phase of F(x; y).
//PROBLEM 2, 3
2. Keep the magnitude of F(x; y) and set the phase to 0 for each
frequency sample. Take the inverse DFT and compare the results to the
original image.
3. Keep the phase of F(x; y) and set the magnitude to unity for each
frequency sample. Take the inverse DFT and compare the results to the
original image.
//FINE
4. Keep the phase of F(x; y) and replace the magnitude of each frequency
sample by its square root. Take the inverse DFT and compare the results
to the original image. You should observe an edge enhancement.

Hint: You will need to use the following functions: imread, fft2, ifft2,
fftshift, abs, angle.

The function descriptions of MATALAB
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/ifft2.html

Nick Efford http://www.comp.leeds.ac.uk/nde/book/index.html
has a set of classes that include ImageFFT which extends the
functionality of Java 2D and his custom FFT implementation
and I used that before switching to JAI

The output images from ImageFFT and MATALAB, for Steps 2 & 3 are OK but
the ones from JAI are NOT

Cheers!

Brian Burkhalter wrote:

>Hello.
>
>You indicated somewhere that you were also using Matlab so I guess you want to
>get the same results with JAI. Do you have a mathematical statement of what
>Matlab is doing for the inverse Fourier transform of the magnitude-only image?
>
>My complex analysis is a bit stale but I would expect that if you are trying
>to do
>
> IDFT(Magnitude(DFT(image)))
>
>then you would end up in most cases with a complex-valued image in which case
>you would use the REAL_TO_COMPLEX setting. Note that if you are starting with
>a single-band real image then using REAL_TO_COMPLEX should give you the same
>result as if you were starting from a 2-band image with the first band being
>the single-band image and the second band zero and using the
>COMPLEX_TO_COMPLEX setting.
>
>Brian
>
>On Fri, 20 May 2005, Mahalingam Gopalan wrote:
>
>
>
>>Hi Brian, Thanx for that...I figured as much but unfortunately that
>>doesnt answer my question...I hope am explaining my problem a bit
>>clearly here
>>
>>//This is fine
>>Input Image -> DFT -> Complex Image ->IDFT (COMPLEX_TO_REAL) -> Outut
>>Image (same as input)
>>
>>//Second process
>>Step1 Input Image -> DFT -> Complex Image ->Split into Mag (REAL)
>>and Phase (REAL) images //this is fine
>>//Here is my problem
>>Step2 Mag Image (from Step1) -> IDFT (DFTNature---WHAT?) -> Image
>>similar to input image with NO phase information //HOW TO?
>>Step3 Phase Image (from Step1) -> IDFT (DFTNature---WHAT?) -> Image
>>similar to input image with NO magnitude information //HOW TO?
>>
>>//This is fine
>>Step4 Generate Random Phase Image-> PolarToComplex (Mag Image from
>>Step1 AND Generated RANDOM Phase) -> Complex Image -> IDFT
>>(COMPLEX_TO_REAL) -> REAL Output Image
>>
>>My problem is at Step 2 and 3.
>>
>>I hv tried using REAL_TO_COMPLEX
>>Step2 Mag Image (from Step1) -> IDFT (REAL_TO_COMPLEX) -> Complex
>>Output Image ->Split into Mag and Phase (Neither Mag nor phase
>>consistent with results from Matalab or other APIs)
>>Step3 Phase Image (from Step1) ->REAL_TO_COMPLEX) Same process as
>>above ->(Neither Mag nor phase consistent with results from Matalab or
>>other APIs)
>>
>>I hv tried using COMPLEX_TO_REAL...similar to Step4 BUT...I use a blank
>>image with all pixels set to ZERO
>>Step2 Generate ZERO Phase Image-> PolarToComplex (Mag Image from
>>Step1 AND ZERO Phase) -> Complex Image -> IDFT (COMPLEX_TO_REAL) ->
>>Output Inconsistent with Matalab
>>Step3 Generate ZERO Mag Image -> PolarToComplex (ZERO Mag Image AND
>>Phase from Step 1) -> Complex Image -> IDFT (COMPLEX_TO_REAL) -> Output
>>Inconsistent with Matalab
>>
>>I *know* how the output should look if I have
>>*only* mag info
>>*only* phase info
>>*random* phase with original mag
>>
>>But I am not able to get the results using JAI but with the same input
>>image I hv correct verified results from Matalab but the rest of my
>>software is using JAI
>>
>>Thank for your time....
>>
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
>For additional commands, e-mail: interest-help@jai.dev.java.net
>
>
>

--
Mahalingam Gopalan
Texture Lab 1.69 / G29
School of Mathematics and Computer Science
Heriot-Watt University

If we knew what it was we were doing, it would not be called research,
would it?
- Albert Einstein

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net

Mahalingam Gopalan

A duplicate post...Please read below....Any suggestions?

Mahalingam Gopalan wrote:

> Hi Brian,
>
> Apologies for the delay in getitng back to you...This is part of a
> coursework description for my postgraduate study a couple of years ago
> and the course is still running :-)
>
> Description
> You are asked to write a MATLAB program to perform the following tasks
> for each of the given test images Lena.jpg and Beckman.jpg:
>
> //FINE
> 1. Compute the DFT F(x; y) and display the magnitude and phase of F(x;
> y).
> //PROBLEM 2, 3
> 2. Keep the magnitude of F(x; y) and set the phase to 0 for each
> frequency sample. Take the inverse DFT and compare the results to the
> original image.
> 3. Keep the phase of F(x; y) and set the magnitude to unity for each
> frequency sample. Take the inverse DFT and compare the results to the
> original image.
> //FINE
> 4. Keep the phase of F(x; y) and replace the magnitude of each
> frequency sample by its square root. Take the inverse DFT and compare
> the results to the original image. You should observe an edge
> enhancement.
>
> Hint: You will need to use the following functions: imread, fft2,
> ifft2, fftshift, abs, angle.
>
> The function descriptions of MATALAB
> http://www.mathworks.com/access/helpdesk/help/techdoc/ref/ifft2.html
>
> Nick Efford http://www.comp.leeds.ac.uk/nde/book/index.html
> has a set of classes that include ImageFFT which extends the
> functionality of Java 2D and his custom FFT implementation
> and I used that before switching to JAI
>
> The output images from ImageFFT and MATALAB, for Steps 2 & 3 are OK
> but the ones from JAI are NOT
>
> Cheers!
>
> Brian Burkhalter wrote:
>
>> Hello.
>>
>> You indicated somewhere that you were also using Matlab so I guess
>> you want to
>> get the same results with JAI. Do you have a mathematical statement
>> of what
>> Matlab is doing for the inverse Fourier transform of the
>> magnitude-only image?
>>
>> My complex analysis is a bit stale but I would expect that if you are
>> trying
>> to do
>>
>> IDFT(Magnitude(DFT(image)))
>>
>> then you would end up in most cases with a complex-valued image in
>> which case
>> you would use the REAL_TO_COMPLEX setting. Note that if you are
>> starting with
>> a single-band real image then using REAL_TO_COMPLEX should give you
>> the same
>> result as if you were starting from a 2-band image with the first
>> band being
>> the single-band image and the second band zero and using the
>> COMPLEX_TO_COMPLEX setting.
>>
>> Brian
>>
>> On Fri, 20 May 2005, Mahalingam Gopalan wrote:
>>
>>
>>
>>> Hi Brian, Thanx for that...I figured as much but unfortunately that
>>> doesnt answer my question...I hope am explaining my problem a bit
>>> clearly here
>>>
>>> //This is fine
>>> Input Image -> DFT -> Complex Image ->IDFT (COMPLEX_TO_REAL) -> Outut
>>> Image (same as input)
>>>
>>> //Second process
>>> Step1 Input Image -> DFT -> Complex Image ->Split into Mag (REAL)
>>> and Phase (REAL) images //this is fine
>>> //Here is my problem
>>> Step2 Mag Image (from Step1) -> IDFT (DFTNature---WHAT?) -> Image
>>> similar to input image with NO phase information //HOW TO?
>>> Step3 Phase Image (from Step1) -> IDFT (DFTNature---WHAT?) -> Image
>>> similar to input image with NO magnitude information //HOW TO?
>>>
>>> //This is fine
>>> Step4 Generate Random Phase Image-> PolarToComplex (Mag Image from
>>> Step1 AND Generated RANDOM Phase) -> Complex Image -> IDFT
>>> (COMPLEX_TO_REAL) -> REAL Output Image
>>>
>>> My problem is at Step 2 and 3.
>>>
>>> I hv tried using REAL_TO_COMPLEX
>>> Step2 Mag Image (from Step1) -> IDFT (REAL_TO_COMPLEX) -> Complex
>>> Output Image ->Split into Mag and Phase (Neither Mag nor phase
>>> consistent with results from Matalab or other APIs)
>>> Step3 Phase Image (from Step1) ->REAL_TO_COMPLEX) Same process as
>>> above ->(Neither Mag nor phase consistent with results from Matalab or
>>> other APIs)
>>>
>>> I hv tried using COMPLEX_TO_REAL...similar to Step4 BUT...I use a blank
>>> image with all pixels set to ZERO
>>> Step2 Generate ZERO Phase Image-> PolarToComplex (Mag Image from
>>> Step1 AND ZERO Phase) -> Complex Image -> IDFT (COMPLEX_TO_REAL) ->
>>> Output Inconsistent with Matalab
>>> Step3 Generate ZERO Mag Image -> PolarToComplex (ZERO Mag Image
>>> AND
>>> Phase from Step 1) -> Complex Image -> IDFT (COMPLEX_TO_REAL) -> Output
>>> Inconsistent with Matalab
>>>
>>> I *know* how the output should look if I have
>>> *only* mag info
>>> *only* phase info
>>> *random* phase with original mag
>>>
>>> But I am not able to get the results using JAI but with the same input
>>> image I hv correct verified results from Matalab but the rest of my
>>> software is using JAI
>>>
>>> Thank for your time....
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
>> For additional commands, e-mail: interest-help@jai.dev.java.net
>>
>>
>>
>

--
Mahalingam Gopalan
Texture Lab 1.69 / G29
School of Mathematics and Computer Science
Heriot-Watt University

If we knew what it was we were doing, it would not be called research,
would it?
- Albert Einstein

---------------------------------------------------------------------
To unsubscribe, e-mail: interest-unsubscribe@jai.dev.java.net
For additional commands, e-mail: interest-help@jai.dev.java.net