[Insight-users] Insight-users Digest Questions - Problems Building FFTW From Review

Calvin Lefebvre calvin.lefebvr7 at gmail.com
Wed Nov 23 15:39:31 EST 2011


Hi Antonio,

That makes a lot of sense, thanks!

Now I have the problem that I want to do a pixel multiplication between the
FFTW image and a filter. My filter image is 160*160*80 but now my FFTW
image is 81*160*80 (). Do I solve this by doing the following:

1. Make a new image of size 160*160*80
2. Paste the FFTW image on the left half of the new image
3. Take the reflection of the FFTW image and then flip on the x axis
4. Paste results from 3 into the right side of the new image
5. Now the new image would be the full FFTW image (160*160*80) and it can
be multiplied by my filter

Note: My filter is not symmetric so I can not just cut it in half.

It seems like they are wanting to save time by removing redundant info but
if I have to do the above, I feel like over all it would take longer.

Thanks again for all the help, I really appreciate it.

Calvin


2011/11/23 Antonio Gómez Barquero <agb1 at alu.upct.es>

> ** **
>
> Hi****
>
> ** **
>
> I have used another complex to real function, and the treatment of the
> result is not so easy …it took me some time some months ago! Here you have
> the info I get by an example:****
>
> ** **
>
> First, we have this matrix:****
>
> ** **
>
> ********
>
> ** **
>
> The next matrix ‘B’ is the theoretical result of the fft for example doing
> it with Matlab :****
>
> ****** **
>
> ********
>
> ** **
>
> As the result is real, there is redundant info, for taking advance of this
> point, fftw takes the firs ‘n1/2 +’ colummns of the ‘B’ matrix.****
>
> ** **
>
> And the places of the result in fftw is the following one (take care that
> is a 2D matrix ), the whole info that you need can be extracted from the
> two first columns or the first row .****
>
> ** **
>
> ********
>
> ** **
>
> I don’t know why in the fftw manual is not well explicated…****
>
> ** **
>
> Hope it helps****
>
> ** **
>
> Antonio****
>
> ** **
>
> ** **
>
> ** **
>
> *De:* Calvin Lefebvre [mailto:calvin.lefebvr7 at gmail.com]
> *Enviado el:* miércoles, 23 de noviembre de 2011 4:18
>
> *Para:* Antonio Gómez Barquero
> *CC:* insight-users at itk.org
> *Asunto:* Re: [Insight-users] Insight-users Digest Questions - Problems
> Building FFTW From Review****
>
> ** **
>
> Hi Antonio,
>
> I think it is fixed, I just put
>
> PATH=%PATH%;C:\Users\...\FFTW_LIBS
>
> into my debugging environment. I ran into another problem though. When I
> do the FFTWRealToComplexConjugateImageFilter the image is right except that
> it cuts my image in half. For example I have an image with 160x160x80
> dimension and after the FFTRealToComplex I get an image with 81x160x80
> dimension. I can not figure out why this is; do you have an idea? I have
> place that part of my code below.
>
> Thanks for the help,
>
> Calvin
>
> My code is:
>
> typedef float  PixelType;
> const unsigned int ImageDimension = 3;typedef itk::Image< PixelType,
> ImageDimension > ImageType;
>
> typedef itk::ImageFileReader<ImageType> ReaderType;ReaderType::Pointer
> reader = ReaderType::New();
> reader->SetFileName(argv[2]);
>
>
> //  FFT filter
> typedef itk::FFTWRealToComplexConjugateImageFilter < PixelType,
> ImageDimension> FFTWFilterType;
>
> FFTWFilterType::Pointer fftFilter =    FFTWFilterType::New();
> fftFilter->SetInput( reader->GetOutput() );
>
> try
> {
>     fftFilter->Update();
> }catch( itk::ExceptionObject & excp )
> {
>     std::cerr << "Error: " << std::endl;
>     std::cerr << excp << std::endl;
> }
>
> unsigned long x =
> fftFilter->GetOutput()->GetLargestPossibleRegion().GetSize()[0];
> unsigned long y =
> fftFilter->GetOutput()->GetLargestPossibleRegion().GetSize()[1];
> unsigned long z =
> fftFilter->GetOutput()->GetLargestPossibleRegion().GetSize()[2];
>
> typedef FFTWFilterType::OutputImageType    SpectralImageType;
>
> typedef itk::ComplexToRealImageFilter<SpectralImageType, ImageType>
> RealFilterType;
> RealFilterType::Pointer RealFFT = RealFilterType::New();
> RealFFT->SetInput(fftFilter->GetOutput());
>
>
> typedef itk::ImageFileWriter<ImageType> WriterType;
> WriterType::Pointer writer2 = WriterType::New();
> writer2->SetFileName( argv[3] );
> writer2->SetInput( RealFFT->GetOutput() );
>
> ****
>
> 2011/11/22 Antonio Gómez Barquero <agb1 at alu.upct.es>****
>
>  ****
>
> Hi!,****
>
>  ****
>
> From your last reply I assume that you solved the problems of all the
> steps, basically all of the steps are done in the internal configuration of
> the Project you are working with in Visual Studio ( and for both modes
> ‘Debug’ and ‘Release’ ) , the bad point is that you have to repeat each
> step each time you build a new project.****
>
>  ****
>
> That error sounds familiar to me, please first  check if that file is
> inside the folder ‘ FFTW_LIBS’ (  which must be inside the project visual
> studio folder).****
>
>  ****
>
> If it is inside another idea that came to my mind is to first create a
>  system environment variable of the system and associated it to the folder
> FFTW_LIBS and call it “PATH_FFTW_LIBS”. Then, in Visual Studio , go to
> “Tools > Options > Projects and Solutions > VC++ Directories > Show
> directories for : ****
>
>  ****
>
> -          “Inclusion files”****
>
> -          “Library files”****
>
> o   And in both places write : $(PATH_FFTW_LIBS)****
>
>  ****
>
> Tell me if it works!****
>
>  ****
>
> You’re welcome!****
>
>  ****
>
> Antonio****
>
>  ****
>
> *De:* Calvin Lefebvre [mailto:calvin.lefebvr7 at gmail.com]
> *Enviado el:* martes, 22 de noviembre de 2011 6:13
> *Para:* Antonio Gómez Barquero
> *CC:* insight-users at itk.org
> *Asunto:* Re: [Insight-users] Insight-users Digest Questions - Problems
> Building FFTW From Review****
>
>  ****
>
> Hi Antonio Gómez Barquero,
>
> Just an update. I completed your steps 1-6 and the project built for the
> first time but now when I go to debug a window pops up and has the
> following message
>
> `The program can't start because libfftw3-3.dll is missing from your
> computer. Try reinstalling the program to fix this problem.'
>
> I did not touch libfftw3-3.dll so I am not sure what happened. Did you
> ever get this error?
>
> Thanks for your help again,
>
> Calvin
>
> ps Sorry for sending twice but I forgot to include insight-users at itk.org**
> **
>
> 2011/11/21 Calvin Lefebvre <calvin.lefebvr7 at gmail.com>****
>
> Hi Antonio Gómez Barquero,
>
> Thank you for your help, I really appreciate it. I just had 3 more
> question if you do not mind.
>
> *Question 1*
>
> I understand up until your step 3 but then there is a gap between step 3
> and step 4.
>
> After step 3 I configure ITK with CMake and I set ITK_USE_REVIEW,
> USE_FFTWD and USE_FFTWF to "On" but the problem is CMake can not find****
>
> FFTWD_LIB****
>
> FFTWD_THREADS_LIB****
>
> FFTWF_LIB ****
>
> FFTWF_THREADS_LIB****
>
> FTTW_INCLUDE_PATH
>
> They are located in FFTW_LIBS so did you have to manually set them to a
> lib? If yes, then which one did you set each of them to?
>
> *Question 2*
>
> Also, another question so in order to use ITK in visual studios I have to
> do the following steps
>
> A.Configure ITK in CMake
> B.Build ITK in visual studios
> C.Configure my project in CMake
> D. Build my project in visual studios
>
> In your steps 4,5,6 you are setting Additional dependencies, Additional
> libs directory and Environment do you do this for both building itk in
> visual studios and building your project in visual studios?
>
> *Question 3*
>
> I just wanted to check if there was a difference in your step 5b and 6?
>
> Thanks again,
>
> Calvin****
>
>  ****
>
> 2011/11/21 Antonio Gómez Barquero <agb1 at alu.upct.es>****
>
>  ****
>
> Hi Calvin****
>
>  ****
>
> I also had the same problem some months ago, and I solved it making some
> changes in the configuration of ‘Visual Studio 2008’, here I tell you the
> process:****
>
>  ****
>
> 1.       Download the file “fftw-3.3dll32.zip from fftw org website (
> http://www.fftw.org/install/windows.html)****
>
>  ****
>
> 2.       In order to link to these .dll files from Visual C++, you need
> to create .lib "import libraries" for them, and can do so with the "lib"
> command that comes with VC++.  In particular, run:****
>
>      lib /def:libfftw3-3.def****
>
>      lib /def:libfftw3f-3.def****
>
>      lib /def:libfftw3l-3.def****
>
>  ****
>
> In “Tools > Visual Studio 2008 Command Prompt” without opening any
> project, just Visual. Once you are in the console, you go with the ‘cd’
> command to the root where the folder is placed and once there you run the
> three lines above, and then the ‘lib files are created.****
>
>  ****
>
> 3.       Copy the folder where the libs are created and then copy it
> inside the project folder where we want to use it and rename the folder to
> “FFTW_LIBS”. In this folder the necessary files are the ones that have the
> ‘*.dll’ , ‘*.lib’ and the ‘fftw3.h’.****
>
>  ****
>
> 4.       Inclusion of the libs in the project: “Project > Properties >
> Configuration Properties > Linker > Entry > Additional dependencies” and
> then we include the three new libs files:****
>
>  ****
>
> libfftw3-3.lib ****
>
> libfftw3f-3.lib****
>
> libfftw3l-3.lib****
>
>  ****
>
> 5.       Inclusion of the path where the libs are:****
>
> a.       “Project > Properties > Configuration Properties > Linker >
> General > Additional libs directory” , and there we write “./FFTW_LIBS”.**
> **
>
> b.      “Project > Properties > Configuration Properties > Depuration >
> Environment” , and there we write “./FFTW_LIBS”.****
>
>  ****
>
> 6.       Inclusion of the path where the ‘.dll’ file is. In “Project >
> Properties > Configuration Properties > Depuration > Environment”. In the
> variable ‘enviroment’ we have to specify where the file ‘libfftw3-3.dll’
> and we write “PATH = .\FFTW_LIBS”****
>
>  ****
>
> After all of this steps, you just have to add “ #include fftw3.h” and use
> the fftw functions!****
>
> My visual Studio is in Spanish, so sorry if any of the word is not perfect
> translated.****
>
>  ****
>
> Hope it helps!****
>
>  ****
>
> Antonio Gómez Barquero****
>
>  ****
>
>  ****
>
>  ****
>
>  ****
>
> *De:* insight-users-bounces at itk.org [mailto:insight-users-bounces at itk.org]
> *En nombre de *Calvin Lefebvre
> *Enviado el:* viernes, 18 de noviembre de 2011 19:07
> *Para:* insight-users at itk.org
> *Asunto:* [Insight-users] Insight-users Digest Questions - Problems
> Building FFTW From Review****
>
>  ****
>
> Hi Insight-users,****
>
>  ****
>
> I am currently trying to use FFTW from the "Review" directory option but I
> am having a great deal of difficulty and I would appreciate any help.****
>
>  ****
>
> *Attempt1*****
>
> * *****
>
> *Step 1*****
>
> * *****
>
> I download the windows version for FFTW dll files from
> http://www.fftw.org/install/windows.html and used lib.exe to create the
> .lib (import libraries). So now I have the following new three lib files:*
> ***
>
>  ****
>
> libfftw3-3.lib****
>
> libfftw3f-3.lib****
>
> libfftw3l-3.lib****
>
>  ****
>
> *Step 2*****
>
>  ****
>
> I then modified the CMakelist for compiling the ITK by adding ****
>
>
> SET(CMAKE_MODULE_PATH ${ITK_SOURCE_DIR}/CMake)
> OPTION(USE_FFTWD "Use double precision FFTW if found" ON)
> OPTION(USE_FFTWF "Use single precision FFTW if found" ON)
> FIND_PACKAGE( FFTW )
>
> IF(USE_FFTWF)
>     LINK_LIBRARIES(${FFTWF_LIB})
> ENDIF(USE_FFTWF)
>
> IF(USE_FFTWD)
>     LINK_LIBRARIES(${FFTWD_LIB})
> ENDIF(USE_FFTWD)****
>
> * *****
>
> *Step 3*****
>
>  ****
>
> Next I configure ITK in CMake. I set ITK_USE_REVIEW, USE_FFTWD and
> USE_FFTWF to "On". I get the following error****
>
>  ****
>
> CMake Error: The following variables are used in this project, but they
> are set to NOTFOUND.****
>
> Please set them or make sure they are set and tested correctly in the
> CMake files:****
>
> FFTWD_LIB (ADVANCED)****
>
> linked by target "ITKAlgorithms" in directory
> C:/Users/clefebvr/Desktop/InsightToolkit-3.20.1/Code/Algorithms****
>
> FFTWF_LIB (ADVANCED)****
>
> linked by target "ITKAlgorithms" in directory
> C:/Users/clefebvr/Desktop/InsightToolkit-3.20.1/Code/Algorithms****
>
> FFTW_INCLUDE_PATH****
>
> ...****
>
>  ****
>
> So, in CMake it mentions that it cannot find FFTWD_LIB, FFTWD_THREADS_LIB,
> FFTWF_LIB, FFTWF_THREADS_LIB and FTTW_INCLUDE_PATH. So I set the path
>   in CMake          as the following****
>
>  ****
>
> FFTWD_LIB, FFTWD_THREADS_LIB to libfftw3-3.lib****
>
> FFTWF_LIB, FFTWF_THREADS_LIB to libfftw3f-3.lib****
>
> FTTW_INCLUDE_PATH to directory of fftw3.h****
>
>  ****
>
> I configured and generated in CMake without any errors and there was no
> problem building ITK in visual studios 2008. When I try and build my own
> project with itkFFTWComplexToComplexImageFilter.h                  I get I
> get several errors that are similar to the following****
>
>  ****
>
> itkGaborImageSourceTest.obj : error LNK2019: unresolved external symbol
> __imp_fftwf_destroy_plan referenced in function "protected: virtual __cdecl
> itk::FFTWComplexToComplexImageFilter<float,2>::~FFTWComplexToComplexImageFilter<float,2>(void)"
> (??1?$FFTWComplexToComplexImageFilter at M$01 at itk@@MEAA at XZ)****
>
>  ****
>
> *Attempt 2*****
>
>  ****
>
> I also tried a different modification to the CMakelist file for the ITK
> configuration by adding ****
>
>  ****
>
> SET(CMAKE_MODULE_PATH ${ITK_SOURCE_DIR}/CMake)****
>
> option(USE_FFTWD "Use double precision fftw if found" ON)****
>
> option(USE_FFTWF "Use single precision fftw if found" ON)****
>
> option(USE_SYSTEM_FFTW "Use an installed version of fftw" OFF)****
>
> if (USE_FFTWD OR USE_FFTWF)****
>
>         if(USE_SYSTEM_FFTW)****
>
>        find_package( FFTW )****
>
>        link_directories(${FFTW_LIBDIR})****
>
>         else(USE_SYSTEM_FFTW)****
>
>        link_directories(${ITK_DIR}/fftw/lib)****
>
>        include_directories(${ITK_DIR}/fftw/include)****
>
>         endif(USE_SYSTEM_FFTW)****
>
> endif(USE_FFTWD OR USE_FFTWF)****
>
>  ****
>
> It did not show any FFTWD_LIB, FFTWD_THREADS_LIB, FFTWF_LIB,
> FFTWF_THREADS_LIB and FTTW_INCLUDE_PATH errors in CMake. Regardless I
> continued and no errors occurred generating in CMake, and building ITK in
> visual studio. Again, when I tried to build my project with
> itkFFTWComplexToComplexImageFilter.h from the Review folder I get several
> errors that are similar to the following****
>
>  ****
>
> itkGaborImageSourceTest.obj : error LNK2019: unresolved external symbol
> __imp_fftwf_destroy_plan referenced in function "protected: virtual __cdecl
> itk::FFTWComplexToComplexImageFilter<float,2>::~FFTWComplexToComplexImageFilter<float,2>(void)"
> (??1?$FFTWComplexToComplexImageFilter at M$01 at itk@@MEAA at XZ)****
>
>  ****
>
>  ****
>
> I compiled CMake with the Visual Studios 2008 64 bit option.****
>
>  ****
>
> Thanks for the help,****
>
>  ****
>
> Calvin****
>
>  ****
>
>  ****
>
>  ****
>
> ** **
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20111123/11e7e23d/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 8319 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20111123/11e7e23d/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 1703 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20111123/11e7e23d/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 315 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20111123/11e7e23d/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 4361 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20111123/11e7e23d/attachment-0003.png>


More information about the Insight-users mailing list