02-07-2018 01:15 PM
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
Solved! Go to Solution.
02-07-2018 01:23 PM - edited 02-07-2018 01:24 PM
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?
02-07-2018 01:28 PM - edited 02-07-2018 01:29 PM
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?
02-07-2018 02:29 PM
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?
02-07-2018 02:54 PM - edited 02-07-2018 03:00 PM
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.
02-07-2018 03:04 PM
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.
02-07-2018 03:07 PM - edited 02-07-2018 03:12 PM
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!
(If you want to graph the RE instead, you might need to offset because some of it could be negative, not sure)
02-07-2018 03:19 PM
My bad! I have changed my code accordingly. But now I get a black image with a white dot at the center instead.
02-07-2018 03:38 PM - edited 02-07-2018 03:38 PM
How does the orange array look like after the Abs? Put in in an intensity graph to see.
02-07-2018 03:43 PM
I placed an intensity graph after the Abs. It looks pretty bad to me.