LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Converting image to array, performing FFT of 2D array, and converting array back to image

Solved!
Go to solution

Hello,

I have a system where I need to convert an image to an array, perform an FFT of the array, and then convert the array back to an image.  I'm aware that I could just use IMAQ FFT to get an FFT of my image, which would get me the results I want, but it slows down our main program considerably.  The current method I am trying is not producing the same results as the IMAQ FFT and I was wondering if anyone had any idea as to why that was happening.  I have attached a sample code that would eventually be added to our main code and the image I have been testing with.

 

Thank you

Download All
0 Kudos
Message 1 of 14
(3,907 Views)

Sorry, no IMAQ installed here, but you might have to scale the transformed DBL array back into the U8 range. 

 

Please be more specific when you say "not the same result". (As I said, your VI is broken because I don't have the toolkit). Can you also attach the transformed images using both methods so we can compare? Are they somewhat similar or completely different?

0 Kudos
Message 2 of 14
(3,902 Views)

Sorry, here are the images.  They seem to be producing a vaguely similar shape, but I need the non-IMAQ FFT to display something similar to the IMAQ FFT.

 

And can you explain more what you mean by scale back the DBL?

0 Kudos
Message 3 of 14
(3,895 Views)

wrote:

 

And can you explain more what you mean by scale back the DBL?


The transform is a complex 2D array and the magnitude could exceed the allowed U8 range of 0..255. So you might want to take the magnitude of the complex (abs works fine for that!, but maybe you want the real or imaginary part. Who knows?) and divide by the array max and multiply by 255, then convert to U8 before continuing. What is the max absolute array value after the transform?

0 Kudos
Message 4 of 14
(3,867 Views)

Thank you for your help so far!  Unfortunately, I seem to still be having trouble.  I've changed my code a bit to match what I think you said, but now I just get a white image.  Did I misunderstand what you wrote?

 

Also the max value after taking the absolute value of the FFT is 108.

0 Kudos
Message 5 of 14
(3,861 Views)

Ok, I just realized I was making a really stupid multiplication error because I'm tired.  I have corrected that, but now I am getting a totally black image.

0 Kudos
Message 6 of 14
(3,855 Views)

Don't take the absolute value of the RE part. Take the abs of the complex if you just want the magnitude!

 

Also, don't multiply by a 2D array with one element. Multiply by a scalar 255!

 

ScaleFFT.png

 

(If you want to graph the RE instead, you might need to offset because some of it could be negative, not sure)

0 Kudos
Message 7 of 14
(3,851 Views)

My bad!  I have changed my code accordingly.  But now I get a black image with a white dot at the center instead.

0 Kudos
Message 8 of 14
(3,844 Views)

How does the orange array look like after the Abs? Put in in an intensity graph to see.

0 Kudos
Message 9 of 14
(3,839 Views)

I placed an intensity graph after the Abs.  It looks pretty bad to me.

Download All
0 Kudos
Message 10 of 14
(3,835 Views)