JTransforms FFT on the image

I have an image that I want to convert to the frequency domain using FFT, it seems that for Java there are not enough libraries for them, but I found two. One of them is JTransforms, and the other is less known and has no name.

With the lesser known of them, 2D could only have lengths of degrees of two, but it had simple methods like FastFourierTransform.fastFT(real, imaginary, true); , and the real one was a two-dimensional array of doublings, full of all pixel values, and the imaginary part was a 2D array of the same size as zeros. The boolean value will depend on the forward or reverse conversion. It made sense to me, and it worked, except for the strength of the two requirements that ruined any transformation I did (initially I added black space around the image to fit its maximum power), which I struggle with, use equivalent methods to JTransforms and would appreciate any advice with this. I will tell you what I'm doing right now.

I believe that the corresponding class will be DoubleFFT_2D , its constructor takes up several rows and columns, which I would call the width and height of my image. Since my image does not have imaginary parts, I think I can use doubleFFT.realForwardFull(real); which treats the imaginary parts as zero and transmits a real 2D array full of pixels. Unfortunately, this does not work at all. JavaDoc state the input array must be of size rows*2*columns, with only the first rows*columns elements filled with real data But I don’t see how this relates to my image and what I need to do to fulfill this requirement.

Sorry for the lengthy and poor explanation, if any additional information is needed, I would be happy to provide it.

The JTransforms library and documents can be found here: https://sites.google.com/site/piotrwendykier/software/jtransforms

+6
source share
1 answer

Too bad that the documentation for JTransforms is not available on the Internet except for the zipped download . It is very complete and useful, you should check it out!

To answer your question: DoubleFFT_2D.realForwardFull(double[][] a) takes an array of real numbers (your pixels). However, the FFT result will have two output values ​​for each input value - the real and imaginary parts of each frequency hopper. This is why your input array should be twice as large as the actual image array, with half its empty / filled with zeros.

Please note that all FFT functions use a not only for input, but also for output - this means that any image data there will be lost, so it may be advisable to copy to another larger array!

An easy and obvious solution for your scenario would be to use DoubleFFT_2D.realForward(double[][] a) . This will only calculate the positive spectrum, because the negative side will be symmetrical to it. This is because your input values ​​are real.

Also, check out the RealFFTUtils_2D class in JTransforms, which will make it easier for you to get your results from the array later :)

+5
source

All Articles