[Insight-users] Re: Building and running examples

Luis Ibanez luis.ibanez at kitware.com
Mon Oct 24 15:06:34 EDT 2005


Hi Xiang,


Please read the tutorials

http://www.itk.org/HTML/Tutorials.htm

in particular the "Getting Started I"

http://www.itk.org/CourseWare/Training/GettingStartedI-WebPage/index.htm


Where you will find details on how to
write and interpret a CMakeLists.txt file.

You should also look at the introductory
chapter of the ITK Software Guide

   http://www.itk.org/ItkSoftwareGuide.pdf

You will also find there instructions on
the content of CMakeLists.txt files


Regarding your questions


1) How to run the examples:

    Simply open a MS-DOS window, or a Cygwin shell,
    go to the directory where the executable of
    the example is, and type:

     ImageRegistration1 fixedImage.png
                        movingImage.png
                        resampledMovingImage.png
                        differenceAfter.png
                        differenceBefore.png


     all in a single command line.

     The images used in this example can be found in
     the directory:

            Insight/Code/Examples/


2) CMake takes care of Library dependencies for you.
    So, when you link to ITKIO, CMake knows that ITKIO
    depends on ITKCommon, and therefore kindly adds
    ITKCommon to your link line. As a consequence, you
    don't always have to list all the basic libraries,
    specially if you are listing the advanced ones.





   Regards,



      Luis




-----------------
Xiang, Hong wrote:
> Hello hbk, Vince and Wordon,
>  
> I have two naive questions, hope to get some help:
>  
> 1). Can smeone kindly show how to pass the exampe data files (below) to the
> program in running the first example (ImageRegistration1.cxx)?
>     (What does the following do during build, as seen in the CMakeLists.txt
> found in Examples\Registration)?
>  
> ADD_TEST(ImageRegistration1oTest ${REGISTRATION_EXAMPLESO}
>   --compare ${BASELINE}/ImageRegistration1Test.png
>             ${TEMP}/ImageRegistration1Test.png
>   ImageRegistration1oTest
>         ${ITK_SOURCE_DIR}/Examples/Data/BrainProtonDensitySliceBorder20.png
>         ${ITK_SOURCE_DIR}/Examples/Data/BrainProtonDensitySliceShifted13x17y.png
>         ${TEMP}/ImageRegistration1Test.png
>         ${TEMP}/ImageRegistration1DifferenceAfterTest.png
>         ${TEMP}/ImageRegistration1DifferenceBeforeTest.png
> )
>  
> 2). On the CMakeLists.txt, w/o much understanding I observe:
>  
>>From the CMakeLists.txt under
>  
> C:\Program Files\InsightToolkit-2.2.0\Examples\Registration
>  
> I saw: TARGET_LINK_LIBRARIES(ImageRegistration1 ITKNumerics ITKIO)
>  
>>From Vince's CMakeLists.txt template, 
>  
> I saw: TARGET_LINK_LIBRARIES(ImageRegistrationX ITKCommon ITKBasicFilters ITKIO)
>  
> Given the task of running the example ImageRegistration1.cxx, does it make any
> difference by linking to apparently different libraries?
>  
> Regards,
> Hong
> 
> ________________________________
> 
> From: hbk [mailto:hatakeshi at gmail.com]
> Sent: Mon 10/3/2005 3:56 AM
> To: vincent-magnotta at uiowa.edu
> Cc: Xiang, Hong; tanya_lll at yahoo.com; luis.ibanez at kitware.com
> Subject: Re: Building and running examples
> 
> 
> 
> This is my cmake file:
> 
> PROJECT( myProject )
> 
> FIND_PACKAGE ( ITK )
> IF ( ITK_FOUND )
>          INCLUDE( ${ITK_USE_FILE} )
> ELSE( ITK_FOUND )
>             MESSAGE(FATAL_ERROR
>                         "Cannot build without ITK.  Please set ITK_DIR.")
> ENDIF( ITK_FOUND )
> 
> 
> ADD_EXECUTABLE(ImageRegistration ImageRegistration1.cxx )
> TARGET_LINK_LIBRARIES(ImageRegistration ITKNumerics ITKIO)
> 
> 
> 
> ADD_EXECUTABLE(test TestRegistration.cxx)
> TARGET_LINK_LIBRARIES(test ITKNumerics ITKIO)
> 
> 
> 
> ADD_EXECUTABLE(res ResampleImageFilter.cxx)
> TARGET_LINK_LIBRARIES(res ITKNumerics ITKIO)
> 
> 
> ADD_EXECUTABLE(mi ImageRegistration2.cxx)
> TARGET_LINK_LIBRARIES(mi ITKNumerics ITKIO)
> 
> 
> ADD_EXECUTABLE(rg5 ImageRegistration5.cxx)
> TARGET_LINK_LIBRARIES(rg5 ITKNumerics ITKIO)
> 
> ADD_EXECUTABLE(reg3 ImageRegistration3.cxx)
> TARGET_LINK_LIBRARIES(reg3 ITKNumerics ITKIO)
> 
> Do you mean I must change the ITKNumerics to ITKBasicFilters?
> Thanks.
> 
> 2005/10/1, Vincent A. Magnotta <vincent-magnotta at uiowa.edu>:
> 
>>Hong,
>>
>>If I was going to build an example separate from ITK (i.e. outside of
>>the ITK build) I would create a new directory called something like:
>>
>>C:\Program Files\Examples\RegistrationTest
>>
>>and copy the file ImageRegistrationX.cxx into this directory. I would
>>then create a CMakeLists.txt file similar to
>>
>>-------------------------
>>PROJECT(ImageRegistrationX)
>>
>>FIND_PACKAGE(ITK)
>>IF(ITK_FOUND)
>>  INCLUDE(${ITK_USE_FILE})
>>ELSE(ITK_FOUND)
>>  MESSAGE(FATAL_ERROR
>>            "Cannot build my program without ITK.  Please set ITK_DIR.")
>>ENDIF(ITK_FOUND)
>>
>>ADD_EXECUTABLE(ImageRegistrationX ImageRegistrationX.cxx )
>>TARGET_LINK_LIBRARIES(ImageRegistrationX ITKCommon ITKBasicFilters
>>ITKIO)
>>
>>-----------------------------------
>>
>>I would then run cmake and build into a new binary directory like
>>C:\Program Files\Examples\RegistrationTest-Build
>>
>>Vince
> 
> 
> 
> 



More information about the Insight-users mailing list