[Insight-users] FFT in 3D not working?

Luis Ibanez luis.ibanez at kitware.com
Mon Aug 28 17:31:12 EDT 2006


Hi Monica,

Thanks for reporting this.

It seems that the problem is originated from the FindFFTW.cmake
file in the directory:


             Insight/CMake/FindFFTW.cmake


This file is used by CMake for finding all the components needed
by FFTW.

In order to propagate to the rest of code the choices of using FFTWF
or FFTWD, this file adds the following command line definitions to the
compiler flags:

                  ADD_DEFINITION( -DUSE_FFTW )

and/or

                  ADD_DEFINITION( -DUSE_FFTW )


This definitions become available to the tests and examples
inside the ITK source tree, but not to external applications.
Therefore ITK builds fine in the Dashboard, but when external
applications try to use FFTW functionalities, their #ifdef for
USE_FFTWF and USEFFTD will fail because the symbols are not
defined.



One alternative for fixing these definitions is to have the file

             Insight/itkConfigure.h.in

have extra lines that when processed by CMake will be converted
into

             #define USE_FFTWF

and/or
             #define USE_FFTWD

in the itkConfigure.h file.


These lines in itkConfigure.h.in should look like:

           #cmakedefine  USE_FFTWF
           #cmakedefine  USE_FFTWD


Please find attached to this email modified versions of
the FindFFTW.cmake and itkConfigure.h.in files.


Could you use these file in replacement of the ones that
your got from CVS, and give it a try to build your wrapping  ?


   Please let us know how it goes.


     If it works fine for you, then we will commit these changes
     into the CVS repository.



         Thanks



             Luis




--------------------
mhg at unizar.es wrote:
> Dear Luis,
> 
> I have just installed the current version of the InsightToolkit from 
> your CVS
> repository (today's date 2006-08-28). My algorithm is working now with vnl
> library. However, when I try to use the FFTW wrappers I get a bunch of 
> errors.
> It seems as the compiler is not able to find these wrappers although it 
> finds
> the includes.
> 
> As demo, I adapted the code in itkFFTTest.cxx to work in my external 
> project as
> attached.
> 
> The first error given by the compiler is given at line 254:
> 
> function `int itkFFTWF_FFTTest(int, char**)':
> /home/monica/.../app/itkFFTTest.cpp:254: error: `
> FFTWRealToComplexConjugateImageFilter' undeclared in namespace `itk'
> 
> /home/monica/.../app/itkFFTTest.cpp:254: error: syntax error before `,' 
> token
> 
> The installation of fftw library was performed using ./configure 
> --enable-float
> --enable-threads so the fftw libraries can be found under /usr/local 
> folders.
> The installation of InsightToolkit library was performed enabling the flag
> USE_FFTWF to ON and these variables were automatically set to
> 
> FFTWF_LIB                        /usr/local/lib/libfftw3f.a
> FFTWF_THREADS_LIB                /usr/local/lib/libfftw3f_threads.a
> FFTW_INCLUDE_PATH                /usr/local/include
> 
> Is there any bug in this CVS version of the library?
> Am I doing something wrong?
> 
> Thanks in advance.
> 
> Another minor issue: when I compile my executables I get these warnings. Is
> there any problem with that?
> 
> /usr/lib/gcc-lib/i586-suse-linux/3.3.5/../../../../i586-suse-linux/bin/ld:
> `.gnu.linkonce.t._ZN3itk25SpatialOrientationAdapterILi3EE18ToDirectionCosinesERKNS_18SpatialOrientation31ValidCoordinateOrientationFlagsE' 
> 
> referenced in section `.rodata' of
> /home/monica/src/lib/InsightToolkit/libITKIO.a(itkNiftiImageIO.o): 
> defined in
> discarded section
> `.gnu.linkonce.t._ZN3itk25SpatialOrientationAdapterILi3EE18ToDirectionCosinesERKNS_18SpatialOrientation31ValidCoordinateOrientationFlagsE' 
> 
> of /home/monica/src/lib/InsightToolkit/libITKIO.a(itkNiftiImageIO.o)
> 
> /usr/lib/gcc-lib/i586-suse-linux/3.3.5/../../../../i586-suse-linux/bin/ld:
> `.gnu.linkonce.t._ZN3itk25SpatialOrientationAdapterILi3EE18ToDirectionCosinesERKNS_18SpatialOrientation31ValidCoordinateOrientationFlagsE' 
> 
> referenced in section `.rodata' of
> /home/monica/src/lib/InsightToolkit/libITKIO.a(itkAnalyzeImageIO.o): 
> defined in
> discarded section
> `.gnu.linkonce.t._ZN3itk25SpatialOrientationAdapterILi3EE18ToDirectionCosinesERKNS_18SpatialOrientation31ValidCoordinateOrientationFlagsE' 
> 
> of /home/monica/src/lib/InsightToolkit/libITKIO.a(itkAnalyzeImageIO.o)
> 
> Thanks again!!
> 
> Quoting Luis Ibanez <luis.ibanez at kitware.com>:
> 
>>
>> Hi Monica,
>>
>>
>> There was a bug in the netlib function that VnlFFT uses for computing
>> the Fourier Transform. This bug has been fixed very recently.
>> (last week).
>>
>>
>> You may want to checkout the current CVS version of ITK in order to
>> get this bug fix.
>>
>>
>> Note that this bug was for the VnlFFT version.
>> The FFTW version should have worked anyways,
>> did you tried with the FFTW version ?
>>
>>
>>    Please let us know,
>>
>>
>>      Thanks
>>
>>
>>         Luis
>>
>>
>> ---------------------------
>> mhg at unizar.es wrote:
>>
>>> Dear Insight users,
>>>
>>> I am trying to use the class 
>>> itkVnlFFTRealToComplexConjugateImageFilter.h
>>> to get the fft transform of a 3D image. I wrote the code presented avobe
>>> using itk version 2.01 to write the real part of the Fourier transform
>>> of a 3D image. I tested my code with a second order derivative kernel
>>> of 64 x 64 x 64. In the following direction I posted the results:
>>>
>>> http://webmail.unizar.es/DescargarFicheros.php?id0=1157193166.php3NXuyp&idn0=real1.vtk&id1=1157193166.php5tbxOn&idn1=real2.vtk& 
>>> where real1.vtk is the file with the itk computed result and 
>>> real2.vtk is the
>>> file computed with the fft implemented in vtk. Looking at these 
>>> results you can
>>> appreciate that the image computed with the itk code is not correct.
>>>
>>> Maybe there is an error in my code or maybe you already fixed this 
>>> bug in latest
>>> releases of itk. I would appreciate if any of you can tell me what is 
>>> the reason
>>> why my code is not working.
>>>
>>> Best, Monica.
>>>
>>> 
===============================================================



-------------- next part --------------
/* 
 * here is where system computed values get stored these values should only
 * change when the target compile platform changes 
 */

/* what byte order */
#cmakedefine CMAKE_WORDS_BIGENDIAN
#ifdef CMAKE_WORDS_BIGENDIAN
  #define ITK_WORDS_BIGENDIAN 
#endif

/* what threading system are we using */
#cmakedefine CMAKE_USE_PTHREADS
#ifdef CMAKE_USE_PTHREADS
#define ITK_USE_PTHREADS
#endif

#cmakedefine CMAKE_USE_SPROC
#ifdef CMAKE_USE_SPROC
#define ITK_USE_SPROC
#endif

#cmakedefine CMAKE_HP_PTHREADS
#ifdef CMAKE_HP_PTHREADS
#define ITK_HP_PTHREADS
#endif

#cmakedefine CMAKE_USE_WIN32_THREADS
#ifdef CMAKE_USE_WIN32_THREADS
#define ITK_USE_WIN32_THREADS
#endif

#cmakedefine ITK_BUILD_SHARED_LIBS
#ifdef ITK_BUILD_SHARED_LIBS
#define ITKDLL
#else
#define ITKSTATIC
#endif

#cmakedefine CMAKE_NO_STD_NAMESPACE
#cmakedefine CMAKE_NO_ANSI_STREAM_HEADERS
#cmakedefine CMAKE_NO_ANSI_STRING_STREAM
#cmakedefine CMAKE_NO_ANSI_FOR_SCOPE
#cmakedefine ITK_CPP_FUNCTION
#cmakedefine ITK_USE_CONCEPT_CHECKING
#cmakedefine ITK_EXPLICIT_INSTANTIATION
#cmakedefine USE_FFTWF
#cmakedefine USE_FFTWD

#define ITK_VERSION_MAJOR @ITK_VERSION_MAJOR@
#define ITK_VERSION_MINOR @ITK_VERSION_MINOR@
#define ITK_VERSION_PATCH @ITK_VERSION_PATCH@
#define ITK_VERSION_STRING "@ITK_VERSION_STRING@"
-------------- next part --------------
## FFTW can be compiled and subsequently linked against
## various data types.
## There is a single set of include files, and then muttiple libraries,
## One for each type.  I.e. libfftw.a-->double, libfftwf.a-->float

## The following logic belongs in the individual package
## MARK_AS_ADVANCED(USE_FFTWD)
## OPTION(USE_FFTWD "Use double precision FFTW if found" ON)
## MARK_AS_ADVANCED(USE_FFTWF)
## OPTION(USE_FFTWF "Use single precision FFTW if found" ON)

IF(USE_FFTWD OR USE_FFTWF)

  SET(FFTW_INC_SEARCHPATH
    /sw/include
    /usr/include
    /usr/local/include
    /usr/include/fftw
    /usr/local/include/fftw
  )

  FIND_PATH(FFTW_INCLUDE_PATH fftw3.h ${FFTW_INC_SEARCHPATH})

  IF(FFTW_INCLUDE_PATH)
    SET(FFTW_INCLUDE ${FFTW_INCLUDE_PATH})
  ENDIF (FFTW_INCLUDE_PATH)

  IF(FFTW_INCLUDE)
    INCLUDE_DIRECTORIES( ${FFTW_INCLUDE})
  ENDIF(FFTW_INCLUDE)

  GET_FILENAME_COMPONENT(FFTW_INSTALL_BASE_PATH ${FFTW_INCLUDE_PATH} PATH)

  SET(FFTW_LIB_SEARCHPATH
    ${FFTW_INSTALL_BASE_PATH}/lib
    /usr/lib/fftw
    /usr/local/lib/fftw
  )

  IF(USE_FFTWD)
    MARK_AS_ADVANCED(FFTWD_LIB)
#   OPTION(FFTWD_LIB "The full path to the fftw3 library (including the library)" )
    FIND_LIBRARY(FFTWD_LIB fftw3 ${FFTW_LIB_SEARCHPATH}) #Double Precision Lib
    FIND_LIBRARY(FFTWD_THREADS_LIB fftw3_threads ${FFTW_LIB_SEARCHPATH}) #Double Precision Lib only if compiled with threads support

    IF(FFTWD_LIB)
      SET(FFTWD_FOUND 1)
      IF(FFTWD_THREADS_LIB)
        SET(FFTWD_LIB ${FFTWD_LIB} ${FFTWD_THREADS_LIB} )
      ENDIF(FFTWD_THREADS_LIB)
    ENDIF(FFTWD_LIB)
  ENDIF(USE_FFTWD)

  IF(USE_FFTWF)
    MARK_AS_ADVANCED(FFTWF_LIB)
#   OPTION(FFTWF_LIB "The full path to the fftw3f library (including the library)" )
    FIND_LIBRARY(FFTWF_LIB fftw3f ${FFTW_LIB_SEARCHPATH}) #Single Precision Lib
    FIND_LIBRARY(FFTWF_THREADS_LIB fftw3f_threads ${FFTW_LIB_SEARCHPATH}) #Single Precision Lib only if compiled with threads support

    IF(FFTWF_LIB)
      SET(FFTWF_FOUND 1)
      IF(FFTWF_THREADS_LIB)
        SET(FFTWF_LIB ${FFTWF_LIB} ${FFTWF_THREADS_LIB} )
      ENDIF(FFTWF_THREADS_LIB)
    ENDIF(FFTWF_LIB)
  ENDIF(USE_FFTWF)

ENDIF(USE_FFTWD OR USE_FFTWF)


More information about the Insight-users mailing list