[ITK] Valid FFT Sizes

Wood, Tobias tobias.wood at kcl.ac.uk
Thu Sep 17 11:05:08 EDT 2015


Hello again,

I added FFTPadImageFilter to my pipeline. The Forward FFT now works, however something weird happens with my Inverse FFT later in the pipeline. My whole pipeline roughly looks like:

1. Load Image
2. Pad
3. Forward FFT
4. Multiply by a filter
5. Inverse FFT
6. Save Image

The pipeline works fine if the input image size is a power of 2. But if it’s not (i.e. pad FFT image is needed), then the output of the Inverse FFT is just blank (all zeros). I checked this two ways:

1. Saving the input of the of the Inverse FFT (output of stage 4) as a complex image and looking at the magnitude and phase. This looks correct (i.e. not blank)
2. Cropping the input image to a subregion that has dimensions that are powers of 2. This produced the expected output.

So does the Inverse FFT have stricter requirements than the Forward FFT? One odd thing I noticed is that FFTPadImageFilter sets the index of the output region to negative values, i.e. for my image with size [416,416,60] the output of padding has size [432,432,60] and index [-8,-8,0], but I assume this is how the padding for x/y<0 works.

My code is on github at https://github.com/spinicist/QUIT/blob/master/Source/qiunwrap.cpp. Apologies for the (ab)use of the C++11 auto keyword.

Toby


On 17/09/2015 14:28, "Community on behalf of Wood, Tobias" <community-bounces at itk.org on behalf of tobias.wood at kcl.ac.uk> wrote:

>Thanks Brad & Corey. That all makes sense. No, I hadn’t seen FFTPadImageFilter, I will add it to my pipeline now.
>
>Toby
>
>
>On 17/09/2015 14:20, "Bradley Lowekamp" <blowekamp at mail.nih.gov> wrote:
>
>>Hello Toby,
>>
>>Have you looked into the FFTPadImageFilter [1], this automatically pad the image as needed.
>>
>>This error message may need to be improved/corrected. If I recall this may be a a restriction on the prime factorization of the image dimensions, not simply that the size is a multiple of one of those numbers but that they are the only valid number for prime factorization...
>>
>>416 prime factorization is 2^5 * 13. Does not work since 13 is a factor
>>450 prime factorization is 5^2*3^2*2  ( eyeball a close number)
>>
>>I think the FFTPad filter should help with this computation.
>>
>>HTH,
>>Brad
>>
>>
>>[1] http://www.itk.org/Doxygen/html/classitk_1_1FFTPadImageFilter.html
>>
>>On Sep 17, 2015, at 7:10 AM, Wood, Tobias <tobias.wood at kcl.ac.uk> wrote:
>>
>>> Hello,
>>> 
>>> I am trying to FFT a moderately large 3D image but am receiving a contradictory error message:
>>> 
>>> itk::ERROR: VnlForwardFFTImageFilter(0x3038500): Cannot compute FFT of image with size [416, 416, 60]. VnlForwardFFTImageFilter operates only on images whose size in each dimension is a multiple of 2, 3, or 5.
>>> 
>>> All the image dimensions are a multiple of 2!  Are the dimensions restricted to be powers of 2/3/5 instead of multiples?
>>> 
>>> I can pad the image out to a sensible size (e.g. 512x512x64), but would like to know if there are any other restrictions I should be aware of before going around in circles? 
>>> 
>>> Thanks,
>>> Toby
>>> 
>>> _______________________________________________
>>> Community mailing list
>>> Community at itk.org
>>> http://public.kitware.com/mailman/listinfo/community
>>
>_______________________________________________
>Community mailing list
>Community at itk.org
>http://public.kitware.com/mailman/listinfo/community


More information about the Community mailing list